Spaces:
Sleeping
Sleeping
fixes
Browse files
app.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def respond(
|
| 6 |
message,
|
|
@@ -8,21 +10,21 @@ def respond(
|
|
| 8 |
temperature,
|
| 9 |
top_p
|
| 10 |
):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
return
|
| 26 |
|
| 27 |
|
| 28 |
demo = gr.Interface(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
API_KEY = os.getenv("access_token")
|
| 6 |
|
| 7 |
def respond(
|
| 8 |
message,
|
|
|
|
| 10 |
temperature,
|
| 11 |
top_p
|
| 12 |
):
|
| 13 |
+
response = requests.post(
|
| 14 |
+
url="https://api.featherless.ai/v1/completions",
|
| 15 |
+
headers={
|
| 16 |
+
"Authorization": f"Bearer {API_KEY}",
|
| 17 |
+
"Content-type": "application/json"
|
| 18 |
+
},
|
| 19 |
+
json={
|
| 20 |
+
"model": "Qwen/Qwen3-8B",
|
| 21 |
+
"prompt": message,
|
| 22 |
+
"max_tokens": max_tokens,
|
| 23 |
+
"temperature": temperature,
|
| 24 |
+
"top_p": top_p
|
| 25 |
+
}
|
| 26 |
+
)
|
| 27 |
+
return response.json()["choices"][0]["text"]
|
| 28 |
|
| 29 |
|
| 30 |
demo = gr.Interface(
|