wop commited on
Commit
91d4bc6
1 Parent(s): ecfea01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
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
- client = Client("https://wop-xxx-opengpt.hf.space/")
23
- result = await client.predict(input_text, 0.9, 2000, 0.9, 1.2, api_name="/chat")
24
- #result = result[:-4]
25
- return result
 
 
 
 
 
 
 
 
 
 
 
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():