muryshev commited on
Commit
be938bc
·
1 Parent(s): 5035f76

Added explicit timeout

Browse files
Files changed (2) hide show
  1. llm/deepinfra_api.py +1 -1
  2. main.py +4 -4
llm/deepinfra_api.py CHANGED
@@ -150,6 +150,6 @@ class DeepInfraApi(LlmApi):
150
  """
151
  async with httpx.AsyncClient() as client:
152
  request = await self.create_request(prompt, system_prompt)
153
- response = await client.post(f"{self.params.url}/v1/openai/chat/completions", headers=super().create_headers(), json=request, timeout=httpx.Timeout(connect=5.0, read=60.0))
154
  if response.status_code == 200:
155
  return response.json()["choices"][0]["message"]["content"]
 
150
  """
151
  async with httpx.AsyncClient() as client:
152
  request = await self.create_request(prompt, system_prompt)
153
+ response = await client.post(f"{self.params.url}/v1/openai/chat/completions", headers=super().create_headers(), json=request, timeout=httpx.Timeout(connect=5.0, read=60.0, write=180, pool=10))
154
  if response.status_code == 200:
155
  return response.json()["choices"][0]["message"]["content"]
main.py CHANGED
@@ -49,15 +49,15 @@ async def extracttable_route(request: TextRequest):
49
 
50
  result = {"response": None, "error": None, "raw": response}
51
 
52
- if "JSON: " not in response:
53
- result["error"] = "Строка не содержит 'JSON: '"
54
  return result
55
 
56
- prefix, json_str = response.split("JSON: ", 1)
57
  json_str = json_str.strip()
58
 
59
  if not json_str:
60
- result["error"] = "После 'JSON: ' отсутствует JSON"
61
  return result
62
 
63
  try:
 
49
 
50
  result = {"response": None, "error": None, "raw": response}
51
 
52
+ if "JSON" not in response:
53
+ result["error"] = "Строка не содержит 'JSON'"
54
  return result
55
 
56
+ prefix, json_str = response.split("JSON", 1)
57
  json_str = json_str.strip()
58
 
59
  if not json_str:
60
+ result["error"] = "После 'JSON' отсутствует JSON"
61
  return result
62
 
63
  try: