Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
API_URL = "https://api-inference.huggingface.co/models/mosaicml/mpt-7b-chat"
|
| 6 |
+
API_KEY = os.getenv('Sec1') # Используем переменную окружения
|
| 7 |
+
|
| 8 |
+
def query(payload):
|
| 9 |
+
response = requests.post(API_URL, headers={"Authorization": f"Bearer {API_KEY}"}, json=payload)
|
| 10 |
+
return response.json()
|
| 11 |
+
|
| 12 |
+
def chatbot(input_text):
|
| 13 |
+
response = query({"inputs": input_text})
|
| 14 |
+
return response[0]['generated_text']
|
| 15 |
+
|
| 16 |
+
demo = gr.Interface(fn=chatbot, inputs="text", outputs="text")
|
| 17 |
+
demo.launch()
|