Skip to content

Commit

Permalink
OpenAI error message (#1354)
Browse files Browse the repository at this point in the history
  • Loading branch information
svetleo-evidently authored Oct 24, 2024
1 parent 15bfe24 commit 35038bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/evidently/utils/llm/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ async def complete(self, messages: List[LLMMessage]) -> str:
messages = [{"role": msg.role, "content": msg.content} for msg in messages]
try:
response = await self.client.chat.completions.create(model=self.model, messages=messages) # type: ignore[arg-type]
except openai.OpenAIError as e:
raise LLMRequestError("Failed to call OpenAI complete API") from e
except openai.APIError as e:
raise LLMRequestError(f"Failed to call OpenAI complete API: {e.message}") from e
content = response.choices[0].message.content
assert content is not None # todo: better error
return content
Expand Down

0 comments on commit 35038bf

Please sign in to comment.