File size: 778 Bytes
4d3834d
7b917b9
8d1ac51
46abf4a
 
4d3834d
 
8d1ac51
 
46abf4a
4d3834d
 
 
0b06987
4d3834d
 
0b06987
 
46abf4a
8d1ac51
46abf4a
 
 
 
 
 
8d1ac51
0b06987
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from transformers import pipeline

# Имя модели
model_name = "nvidia/Hymba-1.5B-Instruct"

# Создание пайплайна
pipe = pipeline("text-generation", model=model_name, trust_remote_code=True)

# Функция для генерации текста
def generate_text(prompt):
    messages = [
        {"role": "user", "content": prompt},
    ]
    try:
        response = pipe(messages)[0]["generated_text"]
        return response
    except Exception as e:
        return f"Ошибка при генерации текста: {str(e)}"

# Gradio интерфейс
interface = gr.Interface(
    fn=generate_text,
    inputs=gr.Textbox(label="Введите запрос"),
    outputs=gr.Textbox(label="Ответ")
)

# Запуск
interface.launch()