ChemDave commited on
Commit
281dde4
·
verified ·
1 Parent(s): d84c1a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -1,13 +1,36 @@
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
  def answer(question):
4
- return f"You asked: {question}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  demo = gr.Interface(
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
  demo.launch()
 
 
1
  import gradio as gr
2
+ import os
3
+ from huggingface_hub import InferenceClient
4
+
5
+ client = InferenceClient(
6
+ api_key=os.environ["HF_TOKEN"]
7
+ )
8
 
9
  def answer(question):
10
+
11
+ try:
12
+ response = client.chat.completions.create(
13
+ model="Qwen/Qwen3-4B-Instruct-2507",
14
+ messages=[
15
+ {
16
+ "role": "user",
17
+ "content": question
18
+ }
19
+ ]
20
+ )
21
+
22
+ return response.choices[0].message.content
23
+
24
+ except Exception as e:
25
+ return f"ERROR: {type(e).__name__}: {str(e)}"
26
+
27
 
28
  demo = gr.Interface(
29
  fn=answer,
30
  inputs=gr.Textbox(label="Ask a chemistry question"),
31
+ outputs=gr.Textbox(label="AI Response"),
32
  title="VR-LAB"
33
  )
34
 
35
  demo.launch()
36
+