gaspar-avit commited on
Commit
657d4a2
·
1 Parent(s): a7ea406

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -190,13 +190,15 @@ def query_generate(text, genres):
190
 
191
  response = requests.post(API_URL, headers=headers, json=payload)
192
 
193
- _="""
194
- if isinstance(response.content, str):
195
- payload = {"inputs": f"{text}",
196
- "options": {"wait_for_model": True},
197
- }
198
- response = requests.post(API_URL, headers=headers, json=payload)
199
- """
 
 
200
 
201
  return response.content
202
 
 
190
 
191
  response = requests.post(API_URL, headers=headers, json=payload)
192
 
193
+ try:
194
+ response_str = response.content.decode("utf-8")
195
+ if 'error' in response_str:
196
+ payload = {"inputs": f"{text}",
197
+ "options": {"wait_for_model": True},
198
+ }
199
+ response = requests.post(API_URL, headers=headers, json=payload)
200
+ except:
201
+ pass
202
 
203
  return response.content
204