Spaces:
Sleeping
Sleeping
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() | |