Skip to content

Commit

Permalink
test: add pydantic v1 compatibility to chat_response_format.py
Browse files Browse the repository at this point in the history
  • Loading branch information
miri-bar committed Aug 21, 2024
1 parent c335204 commit 9bab854
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/studio/chat/chat_response_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from ai21.logger import set_verbose
from ai21.models.chat import ChatMessage, ResponseFormat

from ai21.models.ai21_base_model import IS_PYDANTIC_V2

set_verbose(True)


Expand Down Expand Up @@ -47,6 +49,9 @@ class ZooTicketsOrder(BaseModel):
try:
order = ZooTicketsOrder.model_validate_json(response.choices[0].message.content)
print("Zoo tickets order details JSON:")
print(order.model_dump_json(indent=4))
if IS_PYDANTIC_V2:
print(order.model_dump_json(indent=4))
else:
print(order.json(indent=4))
except ValidationError as exc:
print(exc)

0 comments on commit 9bab854

Please sign in to comment.