Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
def query(data):
|
5 |
+
headers = {
|
6 |
+
"Content-Type": "application/json",
|
7 |
+
"Authorization": "Bearer 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"
|
8 |
+
}
|
9 |
+
|
10 |
+
response = requests.post(
|
11 |
+
"https://api-inference.huggingface.co/models/h2oai/h2ogpt-gm-oasst1-en-1024-12b",
|
12 |
+
headers=headers,
|
13 |
+
json={"inputs": data}
|
14 |
+
)
|
15 |
+
|
16 |
+
result = response.json()
|
17 |
+
return result.get("generated_text", "No response")
|
18 |
+
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=query,
|
21 |
+
inputs=gr.inputs.Textbox(label="Input"),
|
22 |
+
outputs=gr.outputs.Textbox(label="Output"),
|
23 |
+
layout="vertical",
|
24 |
+
title="Hugging Face Chatbot",
|
25 |
+
description="Enter a message to chat with the model.",
|
26 |
+
)
|
27 |
+
|
28 |
+
iface.launch()
|