Spaces:
Sleeping
Sleeping
Create App.py
Browse files
App.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
# Выбираем модель (можно поменять на любую другую из HF)
|
| 5 |
+
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
|
| 6 |
+
|
| 7 |
+
def respond(message, history):
|
| 8 |
+
# Формируем ответ от модели
|
| 9 |
+
response = client.chat_completion(
|
| 10 |
+
messages=[{"role": "user", "content": message}],
|
| 11 |
+
max_tokens=500,
|
| 12 |
+
stream=False
|
| 13 |
+
)
|
| 14 |
+
return response.choices[0].message.content
|
| 15 |
+
|
| 16 |
+
# Создаем интерфейс чата
|
| 17 |
+
demo = gr.ChatInterface(respond)
|
| 18 |
+
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
demo.launch()
|