Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,9 @@ nest_asyncio.apply()
|
|
7 |
|
8 |
ACCESS_TOKEN = os.getenv("HF_TOKEN")
|
9 |
|
|
|
10 |
client = OpenAI(
|
11 |
-
base_url="https://api-inference.huggingface.co/
|
12 |
api_key=ACCESS_TOKEN,
|
13 |
)
|
14 |
|
@@ -25,7 +26,6 @@ def respond(
|
|
25 |
]
|
26 |
|
27 |
try:
|
28 |
-
print("Making request to API...")
|
29 |
response = client.chat.completions.create(
|
30 |
model="NousResearch/Hermes-3-Llama-3.1-8B",
|
31 |
messages=messages,
|
@@ -35,10 +35,9 @@ def respond(
|
|
35 |
)
|
36 |
return response.choices[0].message.content
|
37 |
except Exception as e:
|
38 |
-
print(f"Error: {str(e)}")
|
39 |
return f"Error: {str(e)}"
|
40 |
|
41 |
-
#
|
42 |
iface = gr.Interface(
|
43 |
fn=respond,
|
44 |
inputs=[
|
@@ -49,7 +48,7 @@ iface = gr.Interface(
|
|
49 |
gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P")
|
50 |
],
|
51 |
outputs="text",
|
52 |
-
title="
|
53 |
)
|
54 |
|
55 |
if __name__ == "__main__":
|
|
|
7 |
|
8 |
ACCESS_TOKEN = os.getenv("HF_TOKEN")
|
9 |
|
10 |
+
# Fixed client initialization without proxies
|
11 |
client = OpenAI(
|
12 |
+
base_url="https://api-inference.huggingface.co/models/NousResearch/Hermes-3-Llama-3.1-8B/",
|
13 |
api_key=ACCESS_TOKEN,
|
14 |
)
|
15 |
|
|
|
26 |
]
|
27 |
|
28 |
try:
|
|
|
29 |
response = client.chat.completions.create(
|
30 |
model="NousResearch/Hermes-3-Llama-3.1-8B",
|
31 |
messages=messages,
|
|
|
35 |
)
|
36 |
return response.choices[0].message.content
|
37 |
except Exception as e:
|
|
|
38 |
return f"Error: {str(e)}"
|
39 |
|
40 |
+
# Gradio interface
|
41 |
iface = gr.Interface(
|
42 |
fn=respond,
|
43 |
inputs=[
|
|
|
48 |
gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P")
|
49 |
],
|
50 |
outputs="text",
|
51 |
+
title="Hermes-3-Llama Chat"
|
52 |
)
|
53 |
|
54 |
if __name__ == "__main__":
|