Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def answer(question):
|
| 4 |
-
return f"You asked: {question}"
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
fn=answer,
|
| 8 |
inputs=gr.Textbox(label="Ask a chemistry question"),
|
| 9 |
-
outputs=gr.Textbox(label="Response"),
|
| 10 |
title="VR-LAB"
|
| 11 |
)
|
| 12 |
-
|
| 13 |
-
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
+
client = InferenceClient(
|
| 5 |
+
api_key=os.environ["HF_TOKEN"]
|
| 6 |
+
)
|
| 7 |
def answer(question):
|
|
|
|
| 8 |
|
| 9 |
+
response = client.chat.complete.create(
|
| 10 |
+
model="Qwen/Qwen3-4B-Instruct-2507",
|
| 11 |
+
messages = [{"role": "user",
|
| 12 |
+
"content":"question"
|
| 13 |
+
}
|
| 14 |
+
]
|
| 15 |
+
)
|
| 16 |
+
return response.choices[0].message.content
|
| 17 |
+
demo = gr.interface(
|
| 18 |
fn=answer,
|
| 19 |
inputs=gr.Textbox(label="Ask a chemistry question"),
|
| 20 |
+
outputs=gr.Textbox(label="AI Response"),
|
| 21 |
title="VR-LAB"
|
| 22 |
)
|
| 23 |
+
demo.launch()
|
|
|