Spaces:
Runtime error
Runtime error
Roland Ding
commited on
Commit
·
3a74227
1
Parent(s):
5cef2da
updated the chains.py by llm retry number and async_generate error message
Browse files
chains.py
CHANGED
|
@@ -14,11 +14,11 @@ llm = ChatOpenAI(
|
|
| 14 |
temperature=0.0,
|
| 15 |
model_name="gpt-3.5-turbo-16k",
|
| 16 |
openai_api_key=openai.api_key,
|
| 17 |
-
max_retries=
|
| 18 |
timeout=30 # this one may help me to solve all the old problems...
|
| 19 |
)
|
| 20 |
|
| 21 |
-
retry_decorator = _create_retry_decorator(llm)
|
| 22 |
|
| 23 |
class Replacement(BaseOutputParser):
|
| 24 |
"""Parse the output of an LLM call to a comma-separated list."""
|
|
@@ -33,9 +33,9 @@ class Replacement(BaseOutputParser):
|
|
| 33 |
async def async_generate(article,name,chain,input_variables={}):
|
| 34 |
try:
|
| 35 |
res = await chain.ainvoke(input_variables)
|
| 36 |
-
except
|
| 37 |
-
print("
|
| 38 |
-
article[name] = "Error:
|
| 39 |
return
|
| 40 |
|
| 41 |
print("completed",name)
|
|
|
|
| 14 |
temperature=0.0,
|
| 15 |
model_name="gpt-3.5-turbo-16k",
|
| 16 |
openai_api_key=openai.api_key,
|
| 17 |
+
max_retries=2,
|
| 18 |
timeout=30 # this one may help me to solve all the old problems...
|
| 19 |
)
|
| 20 |
|
| 21 |
+
# retry_decorator = _create_retry_decorator(llm)
|
| 22 |
|
| 23 |
class Replacement(BaseOutputParser):
|
| 24 |
"""Parse the output of an LLM call to a comma-separated list."""
|
|
|
|
| 33 |
async def async_generate(article,name,chain,input_variables={}):
|
| 34 |
try:
|
| 35 |
res = await chain.ainvoke(input_variables)
|
| 36 |
+
except Exception as e:
|
| 37 |
+
print("API Error",str(e))
|
| 38 |
+
article[name] = f"API Error: {str(e)}"
|
| 39 |
return
|
| 40 |
|
| 41 |
print("completed",name)
|