File size: 929 Bytes
f280e4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
import gradio as gr
from groq import Groq

# Инициализация клиента Groq
client = Groq()

# Функция для выполнения запроса к LLM API
def query_llm(prompt):
    completion = client.chat.completions.create(
        model="llama-3.3-70b-versatile",
        messages=[{"role": "user", "content": prompt}],
        temperature=1,
        max_tokens=1024,
        top_p=1,
        stream=True,
        stop=None,
    )

    response = ""
    for chunk in completion:
        response += chunk.choices[0].delta.content or ""
    return response

# Gradio интерфейс
def chat_with_llm(prompt):
    response = query_llm(prompt)
    return response

interface = gr.Interface(
    fn=chat_with_llm, 
    inputs="text", 
    outputs="text",
    title="Chat with LLM",
    description="Введите текст, чтобы отправить запрос к LLM."
)

interface.launch()