Closed BedirT closed 9 months ago
@BedirT do you have a code snippet or steps I can use to recreate this?
Recreating it by:
try:
response = anthropic_client.completions.create(
prompt=f"{anthropic.HUMAN_PROMPT} How many toes do dogs have? {anthropic.AI_PROMPT}",
stop_sequences=[anthropic.HUMAN_PROMPT],
model="claude-2",
max_tokens_to_sample=100,
)
except anthropic.APIConnectionError as e:
print("this is an exception")
Here
import anthropic
import promptlayer
import os
import logging
log = logging.getLogger(__name__)
# promptlayer.api_key = os.environ.get("PROMPTLAYER_API_KEY")
# anthropic = promptlayer.anthropic
anthropic_api_key = os.environ["ANTHROPIC_API_KEY"]
anthropic_ = anthropic.Anthropic(api_key=anthropic_api_key)
try:
response = anthropic_.completions.create(
prompt='Hello there',
max_tokens_to_sample=1000000, # above 100k to get error
model='claude-2'
)
except anthropic.APIConnectionError as e:
log.error("The server could not be reached")
log.error(e.__cause__) # an underlying Exception, likely raised within httpx.
except anthropic.RateLimitError as e:
log.error("A 429 status code was received; we should back off a bit.")
except anthropic.APIStatusError as e:
log.error("Another non-200-range status code was received")
log.error(e.status_code)
log.error(e.response)
@BedirT can you upgrade the python library and try again it should be fixed
Thanks its fixed, though you might want to remove this :)
🤦♂️ Thanks, just removed that ...
Hey,
It seems like the API doesn't properly wrap around the error calls from Claude. Here is the suggested method. I get an error when I try to use it with promptlayer: