add claude3 agent code
This commit is contained in:
@@ -534,17 +534,17 @@ class PromptAgent:
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
if response.json()['error']['code'] == "context_length_exceeded":
|
||||
logger.error("Context length exceeded. Retrying with a smaller context.")
|
||||
payload["messages"] = payload["messages"][-1:]
|
||||
retry_response = requests.post(
|
||||
"https://api.anthropic.com/v1/messages",
|
||||
headers=headers,
|
||||
json=payload
|
||||
)
|
||||
if retry_response.status_code != 200:
|
||||
logger.error("Failed to call LLM: " + retry_response.text)
|
||||
return ""
|
||||
# if response.json()['error']['code'] == "context_length_exceeded":
|
||||
# logger.error("Context length exceeded. Retrying with a smaller context.")
|
||||
# payload["messages"] = payload["messages"][-1:]
|
||||
# retry_response = requests.post(
|
||||
# "https://api.anthropic.com/v1/messages",
|
||||
# headers=headers,
|
||||
# json=payload
|
||||
# )
|
||||
# if retry_response.status_code != 200:
|
||||
# logger.error("Failed to call LLM: " + retry_response.text)
|
||||
# return ""
|
||||
|
||||
logger.error("Failed to call LLM: " + response.text)
|
||||
time.sleep(5)
|
||||
|
||||
Reference in New Issue
Block a user