Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -18,11 +18,23 @@ event = Event()
|
|
18 |
|
19 |
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
|
20 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
21 |
def ask(input_text):
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
async def wait(job):
|
28 |
while not job.done():
|
|
|
18 |
|
19 |
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
|
20 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
21 |
+
|
22 |
def ask(input_text):
|
23 |
+
api_url = "https://somerandomapifor-disorc-cause-i-need-it.onrender.com/qa"
|
24 |
+
params = {'question': input_text}
|
25 |
+
|
26 |
+
response = requests.get(api_url, params=params)
|
27 |
+
|
28 |
+
if response.status_code == 200:
|
29 |
+
json_response = response.json()
|
30 |
+
answer = json_response.get('answer') # Assuming the JSON response has an 'answer' field
|
31 |
+
|
32 |
+
# Applying the operation to the answer
|
33 |
+
modified_answer = answer[:-4] if answer else "No answer found."
|
34 |
+
|
35 |
+
return modified_answer
|
36 |
+
else:
|
37 |
+
return "Error: Unable to fetch response"
|
38 |
|
39 |
async def wait(job):
|
40 |
while not job.done():
|