Roland Ding commited on
Commit
5cef2da
·
1 Parent(s): 721214f

revised the async_generate from chains.py

Browse files

removed the retry_decorator from async_generate.
async_generate will now add the timeout error message in the output
instead of retrying.

On branch main
Changes to be committed:
modified: chains.py

Files changed (1) hide show
  1. chains.py +8 -3
chains.py CHANGED
@@ -28,11 +28,16 @@ class Replacement(BaseOutputParser):
28
  print(kwargs)
29
  return text.strip().split(", ")
30
 
31
- @retry_decorator
32
  @aterminal_print
33
  async def async_generate(article,name,chain,input_variables={}):
34
- res = await chain.ainvoke(input_variables)
35
-
 
 
 
 
 
36
  print("completed",name)
37
  article[name] = res.content
38
 
 
28
  print(kwargs)
29
  return text.strip().split(", ")
30
 
31
+ # @retry_decorator
32
  @aterminal_print
33
  async def async_generate(article,name,chain,input_variables={}):
34
+ try:
35
+ res = await chain.ainvoke(input_variables)
36
+ except TimeoutError:
37
+ print("TimeoutError",name)
38
+ article[name] = "Error: Time out from Openai API"
39
+ return
40
+
41
  print("completed",name)
42
  article[name] = res.content
43