Update main.py
Browse files
main.py
CHANGED
@@ -1,9 +1,22 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
|
4 |
-
|
5 |
-
|
6 |
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from huggingface_hub import InferenceClient
|
3 |
|
4 |
+
# Создаем клиент для модели
|
5 |
+
client = InferenceClient(model="mistralai/Mamba-Codestral-7B-v0.1")
|
6 |
|
7 |
+
def generate_code(prompt):
|
8 |
+
response = client.text_generation(prompt, max_new_tokens=512)
|
9 |
+
return response
|
10 |
|
11 |
+
# Создаем интерфейс Gradio
|
12 |
+
with gr.Blocks() as demo:
|
13 |
+
gr.Markdown("## Mamba-Codestral-7B Code Generator")
|
14 |
+
with gr.Row():
|
15 |
+
prompt_input = gr.Textbox(label="Введите запрос", placeholder="Например: Напишите функцию сортировки на Python")
|
16 |
+
submit_button = gr.Button("Сгенерировать код")
|
17 |
+
output = gr.Code(label="Результат")
|
18 |
+
|
19 |
+
submit_button.click(generate_code, inputs=prompt_input, outputs=output)
|
20 |
+
|
21 |
+
# Запуск интерфейса
|
22 |
+
demo.launch()
|