diff --git a/django_ai_assistant/helpers/assistants.py b/django_ai_assistant/helpers/assistants.py index 28da94c..39598cb 100644 --- a/django_ai_assistant/helpers/assistants.py +++ b/django_ai_assistant/helpers/assistants.py @@ -1,6 +1,5 @@ import abc import inspect -import json import re from typing import Annotated, Any, ClassVar, Dict, Sequence, Type, TypedDict, cast @@ -453,25 +452,6 @@ class AgentState(TypedDict): def setup(state: AgentState): system_prompt = self.get_instructions() - - if self.structured_output: - # If Pydantic - if inspect.isclass(self.structured_output) and issubclass( - self.structured_output, BaseModel - ): - schema = json.dumps(self.structured_output.model_json_schema()) - schema_information = ( - f"Your JSON output must have the following schema:\n{schema}\n" - if schema - else "" - ) - json_info = ( - "In the last step of this chat you will be asked to respond in JSON. " - + schema_information - + "Don't generate JSON until you are explicitly told to. " - ) - system_prompt += "\n" + json_info - return {"messages": [SystemMessage(content=system_prompt)]} def history(state: AgentState): @@ -514,18 +494,23 @@ def tool_selector(state: AgentState): return "continue" def record_response(state: AgentState): + # Structured output must happen in the end, to avoid disabling tool calling. + # Tool calling + structured output is not supported by OpenAI: if self.structured_output: - # Structured output must happen in the end, to avoid disabling tool calling. - # Tool calling + structured output is not supported by OpenAI: - llm_with_structured_output = self.get_structured_output_llm() - response = llm_with_structured_output.invoke( - [ - *state["messages"], - HumanMessage( - content="Use the information gathered in the conversation to answer with JSON." - ), - ] + messages = state["messages"] + + # Change the original system prompt: + if isinstance(messages[0], SystemMessage): + messages[0].content += "\nUse the chat history to produce a JSON output." + + # Add a final message asking for JSON generation / structured output: + json_request_message = HumanMessage( + content="Use the chat history to produce a JSON output." ) + messages.append(json_request_message) + + llm_with_structured_output = self.get_structured_output_llm() + response = llm_with_structured_output.invoke(messages) else: response = state["messages"][-1].content @@ -580,7 +565,7 @@ def invoke(self, *args: Any, thread_id: Any | None, **kwargs: Any) -> dict: return graph.invoke(*args, config=config, **kwargs) @with_cast_id - def run(self, message: str, thread_id: Any | None = None, **kwargs: Any) -> str: + def run(self, message: str, thread_id: Any | None = None, **kwargs: Any) -> Any: """Run the assistant with the given message and thread ID.\n This is the higher-level method to run the assistant.\n @@ -591,7 +576,7 @@ def run(self, message: str, thread_id: Any | None = None, **kwargs: Any) -> str: **kwargs: Additional keyword arguments to pass to the graph. Returns: - str: The assistant response to the user message. + Any: The assistant response to the user message. """ return self.invoke( { @@ -601,7 +586,7 @@ def run(self, message: str, thread_id: Any | None = None, **kwargs: Any) -> str: **kwargs, )["output"] - def _run_as_tool(self, message: str, **kwargs: Any) -> str: + def _run_as_tool(self, message: str, **kwargs: Any) -> Any: return self.run(message, thread_id=None, **kwargs) def as_tool(self, description: str) -> BaseTool: diff --git a/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_pydantic_structured_output.yaml b/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_pydantic_structured_output.yaml index 79fbd62..7d4d196 100644 --- a/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_pydantic_structured_output.yaml +++ b/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_pydantic_structured_output.yaml @@ -1,335 +1,8 @@ interactions: - request: body: '{"messages": [{"content": "You are a helpful assistant that provides information - about people.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. Gather information using tools. Don''t - generate JSON until you are explicitly told to. ", "role": "system"}, {"content": - "Tell me about John who is 30 years old and not a student.", "role": "user"}], - "model": "gpt-4o-2024-08-06", "n": 1, "stream": false, "temperature": 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '470' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAA1RSwW7bMAy9+ysInZ0iTlyny2XoZQOG7rChQA/rECgybWmVRU2km2ZF/32Q4ybb - RRDeI58e9fhaACjXqi0oY7WYIfrFbeO+fzK3rglPvx/oW/Xn7u7rYWUflk19/KzK3EH7X2jkvevK - 0BA9iqNwok1CLZhVq82qqZq6ul5PxEAt+tzWR1nUtFgtV/ViebNYNnOjJWeQ1RZ+FAAAr9OZLYYW - X9QWluU7MiCz7lFtz0UAKpHPiNLMjkUHUeWFNBQEw+T6niAmenYtwpFGODixkNDjsw4CLnSUBp3H - Ab2nUeAL2VCCodG3U330qBmBrU4IAyWEFkU7z0AJpmdeBBL2OrUu9HCwzljgiMZ1zsCjynqPapLK - Cgk7TClXCn2Ee4sJJ3zQ4QgRKXo8WRSrBYIesAQmyKxuW5eNan+2wKOxoBmsYyBjxjhNUoInM98o - gQuCCVkYDtNUFn0E43Vy3XH2GzExhcnkgDpc/fuVCbuRdU4yjN7P+Ns5G099TLTnmT/jnQuO7S6h - Zgo5BxaKamLfCoCf0w6M/8WqYqIhyk7oCUMW3KxPcuqydBfyejOTQqL9Ba/Wy2I2qPjIgsOuc6HH - FJM7bUQXd1W93u9v6g8ro4q34i8AAAD//wMA5g4c6BoDAAA= - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about people.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. JSON will have the following schema:\n\n{\"properties\": - {\"name\": {\"title\": \"Name\", \"type\": \"string\"}, \"age\": {\"title\": - \"Age\", \"type\": \"integer\"}, \"is_student\": {\"title\": \"Is Student\", - \"type\": \"boolean\"}}, \"required\": [\"name\", \"age\", \"is_student\"], - \"title\": \"OutputSchema\", \"type\": \"object\"}\n\nGather information using - tools. Don''t generate JSON until you are explicitly told to. ", "role": "system"}, - {"content": "Tell me about John who is 30 years old and not a student.", "role": - "user"}], "model": "gpt-4o-2024-08-06", "n": 1, "stream": false, "temperature": - 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '811' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAA1RSy27bMBC86ysWvPQiB5LiR+tLUaSXBL0ELdoAQWHQ5FpiTXFZ7iquEfjfC8qK - 3V54mOHMDnf4WgAoZ9UalOm0mD762ael+/rFfj/Yav94d9f2WD+F1cP9D//4lFiVWUHbX2jkTXVj - qI8exVE40yahFsyu9apZ1st509Qj0ZNFn2VtlNmcZk3VzGfV+1m1nIQdOYOs1vBcAAC8jmeOGCz+ - UWuoyjekR2bdolpfLgGoRD4jSjM7Fh1ElVfSUBAMY+pvBDHRi7MIRxrg4KQD6RAS/h6QBS24sKPU - 6/ymEu7feQ+tlg4TWBTtPIPe0iCgIWJiChB0jxYeqAtw6Agcw20FR9SJgbwFHSwEyvdZBotBbuAz - jbM7/YKgwxE4onE7Z2CM4Cgw0HXcGFMHASHYBzpM86VzPE4tgQfTgWbICBkzxCm8C4IJWbjMfp7M - iH/8dzMJdwPrXEwYvJ/w02XVntqYaMsTf8F3LjjuNgk1U8hrZaGoRvZUAPwcKx3+a0nFRH2UjdAe - QzasF6uzn7p+oiu7uJ1IIdH+ijd1VUwJFR9ZsN/sXGgxxeTODe/i5gPWC2PsUs9VcSr+AgAA//8D - AEEAD0DqAgAA - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about people.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. JSON will have the following schema:\n\n{\"properties\": - {\"name\": {\"title\": \"Name\", \"type\": \"string\"}, \"age\": {\"title\": - \"Age\", \"type\": \"integer\"}, \"is_student\": {\"title\": \"Is Student\", - \"type\": \"boolean\"}}, \"required\": [\"name\", \"age\", \"is_student\"], - \"title\": \"OutputSchema\", \"type\": \"object\"}\n\nGather information using - tools. Don''t generate JSON until you are explicitly told to. ", "role": "system"}, - {"content": "Tell me about John who is 30 years old and not a student.", "role": - "user"}, {"content": "To provide you with the requested information, I''ll gather - details about a person named John who is 30 years old and not a student. Do - you have any specific questions or details you want to know about this John, - such as his occupation, interests, or location?", "role": "assistant"}, {"content": - "Use the information gathered in the conversation to answer.", "role": "system"}], - "model": "gpt-4o-2024-08-06", "n": 1, "response_format": {"type": "json_schema", - "json_schema": {"schema": {"properties": {"name": {"title": "Name", "type": - "string"}, "age": {"title": "Age", "type": "integer"}, "is_student": {"title": - "Is Student", "type": "boolean"}}, "required": ["name", "age", "is_student"], - "title": "OutputSchema", "type": "object", "additionalProperties": false}, "name": - "OutputSchema", "strict": true}}, "temperature": 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '1578' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - x-stainless-helper-method: - - beta.chat.completions.parse - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAA1SQwU+DMBjF7/wVzXcGA4zhxs3ExLgYPajxIIaU8gHdStvQEmcW/ndTxoZeeni/ - vpf3vZNHCPAKMgKspZZ1WgR3KX99KYfmvi3l80O6e/z4Xh9xfyjl+9Mb+M6hyj0ye3HdMNVpgZYr - ecasR2rRpUa3cRqlSRwnE+hUhcLZGm2DRAVxGCdBuAnCdDa2ijM0kJFPjxBCTtPrKsoKj5CR0L8o - HRpDG4Ts+okQ6JVwClBjuLFUWvAXyJS0KKfWpxwk7TCHLIedamUOfg60ccIq9HPgpjB2qFDaHLKa - CoPj36Qe68FQd4gchJj18VpNqEb3qjQzv+o1l9y0RY/UKOlqGKs0THT0CPmaJhj+XQW6V522hVUH - lC4w3kbnPFhGX2iUzNAqS8Wir8K1NzcE82MsdkXNZYO97vl5kVoXUbIqy02yjRl4o/cLAAD//wMA - b8XsohoCAAA= - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about people.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. JSON will have the following schema:\n\n{\"properties\": - {\"name\": {\"title\": \"Name\", \"type\": \"string\"}, \"age\": {\"title\": - \"Age\", \"type\": \"integer\"}, \"is_student\": {\"title\": \"Is Student\", - \"type\": \"boolean\"}}, \"required\": [\"name\", \"age\", \"is_student\"], - \"title\": \"OutputSchema\", \"type\": \"object\"}\n\nDon''t generate JSON until - you are explicitly told to. ", "role": "user"}, {"content": "Tell me about John - who is 30 years old and not a student.", "role": "user"}], "model": "gpt-4o-2024-08-06", - "n": 1, "stream": false, "temperature": 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '777' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAA3RSQW7bMBC8+xVTnu3Ake3E8S3tKT21CIoWKApjTa4kNhRXIFdujCB/Lyg7dnro - RYRmOMNZcl4mgPHObGBsS2q7Pszub+fPd48/vj481hWt+Ps3Xn8J1brZ337ipZkWhex+s9U31ZWV - rg+sXuKRtolJubhe31Y31WK1qBYj0YnjUGRNr7OlzKp5tZzN17P5zUnYireczQY/JwDwMn5LxOj4 - 2Wwwn74hHedMDZvNeRNgkoSCGMrZZ6WoZnohrUTlOKb+LG2EzyAs5rMDU5pJcPDR+b13AwX8aaXw - dkiJo4YDoij6IeXBxwYUD6gldZB6XCmA3WCp3MAV7hXaFvOGpxhP6uiAHaMWO2R2kIjCW0rMaYqe - U5ZIAT4qJ86ap5AE0ZYTODqmvaQMGTR7x+VMiiBLjjtvkVnVx+YKH7lEKzkJWQfHUdH5plV0TBEt - o6WM2kefW3ZjgmxbkVBkkkbWtpI5gtCTttCWFE44j64+7iXsGfWQjsneJgadBlbf8RUeahxkQGR2 - 6CQxcs/W197Cx/GyRo0kEGpvyw8F9ElqH3iKmjmgTsxQAeWnD+9fMHE9ZCoFikMIJ/z1XIkgTZ9k - l0/8GT/OvE1MWWJ5/qzSm5F9nQC/xuoN/7TJ9Em6XrcqTxyL4fWqOvqZS9kv7Hp1IlWUwgWvFrf/ - U20dK/mQ3xXYHBP62Fwc5ueY45wmH7Jyt619bDj1yR/7XPfb6+Vit1sv7yprJq+TvwAAAP//AwD6 - zByE2AMAAA== - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about people.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. JSON will have the following schema:\n\n{\"properties\": - {\"name\": {\"title\": \"Name\", \"type\": \"string\"}, \"age\": {\"title\": - \"Age\", \"type\": \"integer\"}, \"is_student\": {\"title\": \"Is Student\", - \"type\": \"boolean\"}}, \"required\": [\"name\", \"age\", \"is_student\"], - \"title\": \"OutputSchema\", \"type\": \"object\"}\n\nDon''t generate JSON until - you are explicitly told to. ", "role": "user"}, {"content": "Tell me about John - who is 30 years old and not a student.", "role": "user"}, {"content": "John - is a 30-year-old individual who is currently not pursuing any form of formal - education. At this age, John may be focused on his career, personal interests, - or other endeavors outside of an academic setting. Being not a student might - mean he has finished his schooling or has chosen a path that does not involve - further education at this time. If you need more specific information or a fictional - profile, feel free to ask!", "role": "assistant"}, {"content": "Use the information - gathered in the conversation to answer.", "role": "user"}], "model": "gpt-4o-2024-08-06", - "n": 1, "response_format": {"type": "json_schema", "json_schema": {"schema": - {"properties": {"name": {"title": "Name", "type": "string"}, "age": {"title": - "Age", "type": "integer"}, "is_student": {"title": "Is Student", "type": "boolean"}}, - "required": ["name", "age", "is_student"], "title": "OutputSchema", "type": - "object", "additionalProperties": false}, "name": "OutputSchema", "strict": - true}}, "temperature": 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '1710' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - x-stainless-helper-method: - - beta.chat.completions.parse - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAAwAAAP//dJBLT8MwEITv+RXWnhOUF6XNjceJEwIJgQiKXGeTGhzbym6lQtX/jpyW - thy4+DCfZzQ720gI0C1UAtRKshq8Sa6v0s3tk1lsZg+L7OamfPy+e/36fPb3xZ16gTg43PIDFf+6 - LpQbvEHWzu6xGlEyhtTsKp/lxWWRzyYwuBZNsPWek9IleZqXSTpP0tnBuHJaIUEl3iIhhNhOb6ho - W9xAJdL4VxmQSPYI1fGTEDA6ExSQRJpYWob4BJWzjHZqva3BygFrqGq4dytbQ1yD7INQpHENmhri - dYuWa6g6aQh350kjdmuS4RC7Nuag747VjOv96JZ04Ee901bTqhlRkrOhBrHzMNFdJMT7NMH6z1Xg - Rzd4bth9og2BRTbf58Fp9BPNygNkx9KcuYr8P1fTIktt6GxI2DfUtj8lpMea051AX8Q4NJ22PY5+ - 1PtdO99kZbFczstFriDaRT8AAAD//wMA7mJmC2ACAAA= - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about people.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. JSON will have the following schema:\n\n{\"properties\": - {\"name\": {\"title\": \"Name\", \"type\": \"string\"}, \"age\": {\"title\": - \"Age\", \"type\": \"integer\"}, \"is_student\": {\"title\": \"Is Student\", - \"type\": \"boolean\"}}, \"required\": [\"name\", \"age\", \"is_student\"], - \"title\": \"OutputSchema\", \"type\": \"object\"}\n\nDon''t generate JSON until - you are explicitly told to. ", "role": "user"}, {"content": "Tell me about John - who is 30 years old and not a student.", "role": "user"}], "model": "gpt-4o-2024-08-06", + about people.", "role": "system"}, {"content": "Tell me about John who is 30 + years old and not a student.", "role": "user"}], "model": "gpt-4o-2024-08-06", "n": 1, "stream": false, "temperature": 1.0}' headers: accept: @@ -341,7 +14,7 @@ interactions: connection: - keep-alive content-length: - - '777' + - '281' content-type: - application/json host: @@ -353,19 +26,17 @@ interactions: method: POST uri: https://api.openai.com/v1/chat/completions response: - content: "{\n \"id\": \"chatcmpl-ABSmfWFBhsprRXk8GBn0KmGd4qn2F\",\n \"object\": - \"chat.completion\",\n \"created\": 1727295617,\n \"model\": \"gpt-4o-2024-08-06\",\n + content: "{\n \"id\": \"chatcmpl-ADHMrJXkTdWFgNbRP8jvg4jQpHSsV\",\n \"object\": + \"chat.completion\",\n \"created\": 1727728389,\n \"model\": \"gpt-4o-2024-08-06\",\n \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": - \"assistant\",\n \"content\": \"John is a 30-year-old individual who - is not currently a student. This could imply that he might have completed his - formal education, or perhaps he chose a different path that did not involve - being a student at present. People of this age might be involved in various - professional endeavors, personal projects, or other pursuits. If there's more - specific information about John or areas you're interested in, feel free to - let me know!\",\n \"refusal\": null\n },\n \"logprobs\": null,\n - \ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": - 152,\n \"completion_tokens\": 83,\n \"total_tokens\": 235,\n \"completion_tokens_details\": - {\n \"reasoning_tokens\": 0\n }\n },\n \"system_fingerprint\": \"fp_7568d46099\"\n}\n" + \"assistant\",\n \"content\": \"I'm sorry, but I need more specific information + to identify the person you're asking about. There are many people named John + who are 30 years old and not students. If you can provide more details, such + as a last name or other context, I might be able to offer some relevant information.\",\n + \ \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 37,\n \"completion_tokens\": + 59,\n \"total_tokens\": 96,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": + 0\n }\n },\n \"system_fingerprint\": \"fp_143bb8492c\"\n}\n" headers: Connection: - keep-alive @@ -385,27 +56,19 @@ interactions: status_code: 200 - request: body: '{"messages": [{"content": "You are a helpful assistant that provides information - about people.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. JSON will have the following schema:\n\n{\"properties\": - {\"name\": {\"title\": \"Name\", \"type\": \"string\"}, \"age\": {\"title\": - \"Age\", \"type\": \"integer\"}, \"is_student\": {\"title\": \"Is Student\", - \"type\": \"boolean\"}}, \"required\": [\"name\", \"age\", \"is_student\"], - \"title\": \"OutputSchema\", \"type\": \"object\"}\n\nDon''t generate JSON until - you are explicitly told to. ", "role": "user"}, {"content": "Tell me about John - who is 30 years old and not a student.", "role": "user"}, {"content": "John - is a 30-year-old individual who is not currently a student. This could imply - that he might have completed his formal education, or perhaps he chose a different - path that did not involve being a student at present. People of this age might - be involved in various professional endeavors, personal projects, or other pursuits. - If there''s more specific information about John or areas you''re interested - in, feel free to let me know!", "role": "assistant"}, {"content": "Use the information - gathered in the conversation to answer.", "role": "user"}], "model": "gpt-4o-2024-08-06", - "n": 1, "response_format": {"type": "json_schema", "json_schema": {"schema": - {"properties": {"name": {"title": "Name", "type": "string"}, "age": {"title": - "Age", "type": "integer"}, "is_student": {"title": "Is Student", "type": "boolean"}}, - "required": ["name", "age", "is_student"], "title": "OutputSchema", "type": - "object", "additionalProperties": false}, "name": "OutputSchema", "strict": - true}}, "temperature": 1.0}' + about people.\nUse the chat history to produce a JSON output.", "role": "system"}, + {"content": "Tell me about John who is 30 years old and not a student.", "role": + "user"}, {"content": "I''m sorry, but I need more specific information to identify + the person you''re asking about. There are many people named John who are 30 + years old and not students. If you can provide more details, such as a last + name or other context, I might be able to offer some relevant information.", + "role": "assistant"}, {"content": "Use the chat history to produce a JSON output.", + "role": "user"}], "model": "gpt-4o-2024-08-06", "n": 1, "response_format": {"type": + "json_schema", "json_schema": {"schema": {"properties": {"name": {"title": "Name", + "type": "string"}, "age": {"title": "Age", "type": "integer"}, "is_student": + {"title": "Is Student", "type": "boolean"}}, "required": ["name", "age", "is_student"], + "title": "OutputSchema", "type": "object", "additionalProperties": false}, "name": + "OutputSchema", "strict": true}}, "temperature": 1.0}' headers: accept: - application/json @@ -416,7 +79,7 @@ interactions: connection: - keep-alive content-length: - - '1716' + - '1108' content-type: - application/json host: @@ -430,14 +93,14 @@ interactions: method: POST uri: https://api.openai.com/v1/chat/completions response: - content: "{\n \"id\": \"chatcmpl-ABSmjxwWBw7Qsaodgl8ghIZ6qzSwB\",\n \"object\": - \"chat.completion\",\n \"created\": 1727295621,\n \"model\": \"gpt-4o-2024-08-06\",\n + content: "{\n \"id\": \"chatcmpl-ADHMskYr2AxG7Ng82ynT2XhCG6Em0\",\n \"object\": + \"chat.completion\",\n \"created\": 1727728390,\n \"model\": \"gpt-4o-2024-08-06\",\n \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"{\\\"name\\\":\\\"John\\\",\\\"age\\\":30,\\\"is_student\\\":false}\",\n \ \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": - \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 316,\n \"completion_tokens\": - 14,\n \"total_tokens\": 330,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": - 0\n }\n },\n \"system_fingerprint\": \"fp_7568d46099\"\n}\n" + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 187,\n \"completion_tokens\": + 14,\n \"total_tokens\": 201,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": + 0\n }\n },\n \"system_fingerprint\": \"fp_2f406b9113\"\n}\n" headers: Connection: - keep-alive diff --git a/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_typeddict_structured_output.yaml b/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_typeddict_structured_output.yaml index 23b4914..676873d 100644 --- a/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_typeddict_structured_output.yaml +++ b/tests/test_helpers/cassettes/test_assistants/test_AIAssistant_typeddict_structured_output.yaml @@ -1,285 +1,9 @@ interactions: - request: body: '{"messages": [{"content": "You are a helpful assistant that provides information - about movies.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. Gather information using tools. Don''t - generate JSON until you are explicitly told to. ", "role": "system"}, {"content": - "Provide information about the movie Shrek. It was released in 2001 and is an - animation and comedy movie.", "role": "user"}], "model": "gpt-4o-2024-08-06", - "n": 1, "stream": false, "temperature": 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '517' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAAwAAAP//bFZRb9xGDn73ryD0dDV2F7brprbf3DhpmsYHw+u74HAuAu6IktidGaqc - kTdKkf9+4EjrdYJ7EXaH5Dfkx4/E/H0EUHFdXUHlOswu9H55/Yoffht+Pb/78s/txe7H3z//ZxPX - N018H+/avlpYhGz+JJf3USsnofeUWeJkdkqYyVBPfz57dfrq/OzipBiC1OQtrO3z8lyWZydn58uT - i+XJqzmwE3aUqiv47xEAwN/laynGmj5XV1BgykmglLCl6urZCaBS8XZSYUqcMsZcLQ5GJzFTLFk/ - VutOaftYASfACBg5WMbgJFA9QsM+QK9SD45q2Ixwo4Tho+g2wXXxZbGoGpQ8YaIaOMLZycnpCh46 - muI5waaYzBVOLy9PoEHWETJ6gp5dHpRgI7IFaSB3BAkDQbTPZoSP7D1jgHUmblfwjpQAlSBJINjS - CDVlZJ8ANzLkEh/kienqMT7GJRwf37CSyyX/4+MruI610g6uawxpTv7f7LYjvKeYZI65O9RcYlQi - fESNpAt4L12Ed6t9YmlRMN5T0yiN8DvmLxQ3pO2EtHZKFHuP44z1QDW88Z4l5wU8kOoI95ISiyET - rDN7HzBOqPfSksJ6ZfetXTeYZcbNqMqxNcjHCLCEW94S3I6kCTBBaSz848mE9MPk8KaumeB20L4b - zeVGovH3jc9rDGTF3jB+MZ875egoJXjLEvFb30LEB85dKzvz/SBaw1vUvwbE+uBq2d4Oid1MwDu0 - mn9VapPE5Z7FiURDvJMdef+yD0VlryX0GAvC/1PhvtcpK2+GQ7tf+N5NUkuT6/0QI8cWMgcqPe57 - lc9F/36EyxMIHIe89/6AsR2wLZ5vYus5dZPhtQwxa7nqX5Ht3nXG57D7aSzgBnMJvcURTi8WZURM - n8fHd14yrIcQsIA8xsNMZvI+TQORRUebDgQl54fET1QIa3UI/QjS6jQw9dz3XSfQcKwTdJwg7TD0 - IE+kOkSbqRfzV3aUsQK5wwwdPhFsiCJsMHLqprG3HOiJ/bctXsGDgFKLHKdrxHMealrMSQTcUgKE - mtDDjnN3EEe2wOQG+l5gVtTGdA0dqbl1HFZw7cU61RHscNzD28pyrqiCpzTRStpiNnbqSdwTKZPS - V3C9nwu7ZrqwpWzXbKPsgNB1ILmzKc8djYXC6VfhJYiSLTgnIUg0wuJk5ciZ0XtjSoa2y6upuffk - qDd1ftfZHRovTjmzQ1+yMUxSx+ghDc4YWcFvuXj2imz7sxEFzgm6IYgu5mXNEhdQRg160kY0oPE5 - rY8kQ6yzotu+2Mfok0BA3VJdmtOjlg3cqITCcVas2YDRv1RKwc7Gc8LMyl+sS3ZLjyr1yFOHQkl7 - Q87Wt0Ta7/SO245SXrZqyy62JZdkVpuFgrMrnFqWmvKSnkjh2mFNYYTrHepEwC+U8jz1VMPbSbzP - VJXaogSOxXwIqLEvs/m8jecOfaAW3feDl3rcRaohDD5z7wkS/TWQTwvg6PxQW/qzN5wtHqvnP5b9 - Q8da26GVtDe8FZ3qaTLp3jiThJC4jdyww5iNzGys9NIPHhXc4J8rLNVxTD1r6V3qOS6laQqXC3is - 7oaUTKC/iOS0vwYh2PY1nRkLRTKrlw8CpWZIaO+ROHg/n399fmF4aXuVTZrtz+cN24L4pIRJor0m - Upa+KtavRwB/lJfM8M3jpOpVQp8/ZdlSNMCL0wmuOjydDsbzy4vZmiWjPxh++vnyaM6wSmPKFD41 - HFvSXnl62DT9p9PzHzebi/PLM1cdfT36HwAAAP//AwBZgHU64QkAAA== - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about movies.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. Gather information using tools. Don''t - generate JSON until you are explicitly told to. ", "role": "system"}, {"content": - "Provide information about the movie Shrek. It was released in 2001 and is an - animation and comedy movie.", "role": "user"}, {"content": "\"Shrek\" is an - animated comedy film produced by DreamWorks Animation and released in 2001. - The film is based on a 1990 fairy tale picture book of the same name by William - Steig. Here are some key details about the movie:\n\n- **Directed by**: Andrew - Adamson and Vicky Jenson\n- **Produced by**: Aron Warner, John H. Williams, - and Jeffrey Katzenberg\n- **Screenplay by**: Ted Elliott, Terry Rossio, Joe - Stillman, and Roger S. H. Schulman\n- **Starring**: \n - Mike Myers as Shrek - (voice)\n - Eddie Murphy as Donkey (voice)\n - Cameron Diaz as Princess Fiona - (voice)\n - John Lithgow as Lord Farquaad (voice)\n- **Music by**: Harry Gregson-Williams - and John Powell\n- **Production Company**: DreamWorks Animation\n- **Distributed - by**: DreamWorks Pictures\n- **Running time**: Approximately 90 minutes\n- **Language**: - English\n- **Country**: United States\n- **Release Date**: May 18, 2001\n\n**Plot - Summary**:\n\"Shrek\" tells the story of a reclusive and grumpy ogre named Shrek - who finds his swamp overrun by fairy tale creatures that have been banished - by the evil Lord Farquaad. To regain his solitude, Shrek makes a deal with Farquaad - to rescue Princess Fiona and bring her to him. Along the way, Shrek is accompanied - by a talkative donkey named Donkey. As Shrek and Fiona get to know each other, - they find they have more in common than they initially thought.\n\n**Reception**:\n\"Shrek\" - was a critical and commercial success. It was praised for its humor, animation, - voice performances, and soundtrack. The film also marked a departure from the - traditional fairy tale format by satirizing and parodying them. It became one - of the highest-grossing films of 2001 and won the first-ever Academy Award for - Best Animated Feature. It was also nominated for Best Adapted Screenplay.\n\n**Legacy**:\n\"Shrek\" - spawned multiple sequels, including \"Shrek 2,\" \"Shrek the Third,\" and \"Shrek - Forever After,\" and became a significant part of popular culture. It also inspired - a spin-off film, \"Puss in Boots,\" and a musical adaptation.", "role": "assistant"}, - {"content": "Use the information gathered in the conversation to answer.", "role": - "system"}], "model": "gpt-4o-2024-08-06", "n": 1, "response_format": {"type": - "json_schema", "json_schema": {"name": "OutputSchema", "description": "dict() - -> new empty dictionary\ndict(mapping) -> new dictionary initialized from a - mapping object''s\n (key, value) pairs\ndict(iterable) -> new dictionary - initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] - = v\ndict(**kwargs) -> new dictionary initialized with the name=value pairs\n in - the keyword argument list. For example: dict(one=1, two=2)", "strict": true, - "schema": {"type": "object", "properties": {"title": {"type": "string"}, "year": - {"type": "integer"}, "genres": {"type": "array", "items": {"type": "string"}}}, - "required": ["title", "year", "genres"], "additionalProperties": false}}}, "temperature": - 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '3406' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - x-stainless-helper-method: - - beta.chat.completions.parse - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAA1SRzW7CMBCE73kKa89JlaRpoLmhHipVqpAKN4yQEzbBxbEte5FKEe9eOYSfXnyY - b2c0uz5FjIHcQsWg2QlqequSWSmX88K6A7bzxRf9LmVRYz2rZx/d+yfEwWHqb2zo6npqTG8VkjT6 - ghuHgjCkZpO8zMoin5YD6M0WVbB1lpLCJHmaF0k6TdJyNO6MbNBDxVYRY4ydhjdU1Fv8gYql8VXp - 0XvRIVS3IcbAGRUUEN5LT0ITxHfYGE2oh9YnDiRJIYeKw2LncM8h5nBE4ThUeZpmMYcOtUPPoVpx - mGnZi7DgMPdmetweOazPj/kO24MXYT19UGrUz7fCynTWmdqP/Ka3Uku/2zgU3uhQzpOxMNBzxNh6 - OMzh365gnektbcjsUYfASZFd8uD+FXeaTUdIhoR6cL28RmND8EdP2G9aqTt01snLnVq7mWKWTSb1 - c1pCdI7+AAAA//8DAEyr8E8wAgAA - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about movies.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. Don''t generate JSON until you are explicitly - told to. ", "role": "user"}, {"content": "Provide information about the movie - Shrek. It was released in 2001 and is an animation and comedy movie.", "role": - "user"}], "model": "gpt-4o-2024-08-06", "n": 1, "stream": false, "temperature": - 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '483' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAA3RWy24cuQ7d+yuIymKAoN1odxI7yc55YTKIB5mJb7K4HhhsiVXFtERW9OhKzSD/ - fiFVP+IB7qbRJVLiIXl4pH/OABq2zUtoTI/J+MGdX1+tvn/8I8nb/u3zD9P22Z8i62ef++HD11// - eNssyg7dfCWTDruWRv3gKLHKbDaBMFE59eJqfbl+8uzJkxfV4NWSK9u6IZ0/1fP1av30fPX8fHW5 - 39grG4rNS/jvGQDAP/W3QBRL35uXsFocVjzFiB01L49OAE1QV1YajJFjQknN4mQ0Komkor5rPvWB - tncNcASEDTndkQUU9gU4GPVkJ2jZeUg9JhgxQiBHGMmCCtzgBBfPF7BerS6WcNvT7FvchqA2G7Kw - meBNIPRfNGwjXNezWQVQLFgOZNLsdC020AjXFn3cmz+z2U7wG0lUWcL7VGBuDrFTT3Dx4sUKWuQw - QUJHMLBJORBsVLegbfWJ6Amk/Gwm+MLOMXr4lIi75Z3cyaNHj+Cj0wSfsvcYpjspacSkYYJWndMx - Qq3SAhACGZcj76jC60L2wwTaBYKxVyD5qlMExzuWDlggquOULZX/PUeII/phCb/qSDsKi7o2EBoq - iVmOKYcNWRh7EkDoguahZFETPK8JVkrlQHEBLMZlWyKZHgOaRKHE3lLN+rYPRPDKsVi4YTMDLoZX - 3MErtPBFXbsADAQ2+4HsA4ylVMWZduzggwYL7zB8y4h2CbcKEXdUnXv1tJjLAx63VFhkCR2MnPrj - HkgKgaLJBB8Di6EY4R2r4KKWjSOkgMMeA0LSkQJ0GYOdmYFgA3aFArd90Nz1mlMN/1VzEJoOCAqJ - TRlCFD7sTOi2mA4dQxGdSsmsypamSgsLb+rHEv4zqIAnSsXj30jnEJaj0V2pdJ2H2NfWiSYYD98l - EywOChtagCOsTUoKWej7MPM9jRxTnDFBTxjSiMHXZqpUjqkc6fm5qAG8xpju5BweP74pTb6ZKMTH - jwH39JxNb61lgpschn6ajXNys/U1egoq8Ibx79n6MMvZ6zftBT5w6jsdZ68HDDig+l0TbhzBtemZ - duRJUiwHnESlyECqmhBi2quIwsjz7F4btOQnuB4xWGg1wCuKaS8QZOHdzPQydgYTdWUgWdJBVliK - 6qyXJeT7WZnQRQVRz1IPOB1pcSgLn0wgksHhVHeVOfe6Y5o3gwmc2KCrXTHqPQXD6CBmU0r0oJWx - DHCx0bdMbm5kHFjOtW3jsXG3PXmKd/JAZ7eio1RwnCL02WtYQMTENdf9lGYxKjuSopQF0TAERdOX - 0D+rwXHwqzrS98FpoFp0T3sxQGNoSCiGFtAGJrGx5+EUiS3hTOYNYU5TgajiJohbFrBEwzGd19ml - XLJ+7wc06V95aZtIYAjIcV/8kl+dBleHQVMPpmdnA83yjja7FBegbUuhFLYWo5q8ljiOYlSZkxsw - qGWqWmF5X5eT9M8t6DHChsq1Vfq5h1ty4U64ZYMy83ABccBRSkyENqCYniPNZZh1lSL47BIPjg5N - XhQm9GUe9nnDenHXHD9m1eVgy2IBczC801DYAtdtolCNEUZyDirr9uxqs4OYsCPwORYW1qofbtRf - ImThb5lg40hsuRT2xKnaMXeTRXR30LrDLZvI9HVnrMUxdU7L+KQIjjo0Zagq9lGDqycfr/8SOS5/ - fjsEanPE8nSR7Nx+/cfxMeK0G4Ju4t5+XG9ZOPb3gTCqlIdHTDo01frjDOCv+ujJD94xzRDUD+k+ - 6ZakHHh1OR/XnF5ZJ+PTy4M1aUJ3Mjx7uv5/2+4tJWQXf3o6NTNClu50wuoIs+bZxCkm8vctS0dh - CDy/pNrh/jldXFxdbZ6sLpuzH2f/AwAA//8DAJBogqdSCgAA - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about movies.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. Don''t generate JSON until you are explicitly - told to. ", "role": "user"}, {"content": "Provide information about the movie - Shrek. It was released in 2001 and is an animation and comedy movie.", "role": - "user"}, {"content": "\"Shrek\" is a beloved animated comedy film that was released - on May 18, 2001. The film was produced by DreamWorks Animation and directed - by Andrew Adamson and Vicky Jenson. It is based on the 1990 fairy tale picture - book of the same name by William Steig.\n\n### Plot Summary\nThe story follows - Shrek, a reclusive and grumpy ogre who enjoys living in solitude in his swamp. - However, his peace is disturbed when a group of fairy-tale creatures, including - characters like the Three Blind Mice and the Big Bad Wolf, are dumped in his - swamp by the evil Lord Farquaad. To save his home, Shrek makes a deal with Farquaad - to rescue Princess Fiona, who is trapped in a tower guarded by a dragon. Throughout - his journey, Shrek is accompanied by a talkative and annoying donkey named Donkey. - Upon meeting Princess Fiona, Shrek discovers that she is not what she appears - to be, leading to unexpected twists and a heartwarming conclusion.\n\n### Voice - Cast\n- **Mike Myers** as Shrek\n- **Eddie Murphy** as Donkey\n- **Cameron Diaz** - as Princess Fiona\n- **John Lithgow** as Lord Farquaad\n\n### Notable Achievements\n- - \"Shrek\" was the first film to win the Academy Award for Best Animated Feature, - a category introduced in 2002.\n- It was also nominated for Best Adapted Screenplay.\n- - The movie was a critical and commercial success, leading to several sequels - and spin-offs.\n\n### Themes\n\"Shrek\" is known for its humor, satire, and - the unconventional approach to fairy-tale characters. It explores themes like - acceptance, friendship, and the idea that beauty is only skin deep.\n\n### Cultural - Impact\n\"Shrek\" is often praised for its appeal to both children and adults, - offering humor and moral lessons. It parodies traditional fairy tales and has - become a culturally significant film, spawning a franchise that includes multiple - sequels, such as \"Shrek 2,\" \"Shrek the Third,\" and \"Shrek Forever After,\" - as well as a successful stage musical.\n\nThe film''s unique blend of humor, - heart, and innovative animation techniques has cemented its legacy in the world - of animated films.", "role": "assistant"}, {"content": "Use the information - gathered in the conversation to answer.", "role": "user"}], "model": "gpt-4o-2024-08-06", - "n": 1, "response_format": {"type": "json_schema", "json_schema": {"name": "OutputSchema", - "description": "dict() -> new empty dictionary\ndict(mapping) -> new dictionary - initialized from a mapping object''s\n (key, value) pairs\ndict(iterable) - -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] - = v\ndict(**kwargs) -> new dictionary initialized with the name=value pairs\n in - the keyword argument list. For example: dict(one=1, two=2)", "strict": true, - "schema": {"type": "object", "properties": {"title": {"type": "string"}, "year": - {"type": "integer"}, "genres": {"type": "array", "items": {"type": "string"}}}, - "required": ["title", "year", "genres"], "additionalProperties": false}}}, "temperature": + about movies.", "role": "system"}, {"content": "Provide information about the + movie Shrek. It was released in 2001 and is an animation and comedy movie.", + "role": "user"}], "model": "gpt-4o-2024-08-06", "n": 1, "stream": false, "temperature": 1.0}' headers: accept: @@ -291,64 +15,7 @@ interactions: connection: - keep-alive content-length: - - '3413' - content-type: - - application/json - host: - - api.openai.com - user-agent: - - OpenAI/Python - x-stainless-helper-method: - - beta.chat.completions.parse - method: POST - uri: https://api.openai.com/v1/chat/completions - response: - body: - string: !!binary | - H4sIAAAAAAAAA3RRPW/bMBTc9SuIN0sFTSu2oy1IinYMkiFAwkCgpSeZNkWy5DMQ1/B/Dyh/dujC - 4e7d4e64zxgD3ULFoFkpagZvioc5/8Knn79nbave/iw6sQ6/1i92M7Pvz38hTwq3XGNDZ9WPxg3e - IGlnj3QTUBEm18lczMT0bnpXjsTgWjRJ1nsqSlcILsqCLwo+OwlXTjcYoWIfGWOM7cc3RbQtfkHF - eH5GBoxR9QjV5YgxCM4kBFSMOpKyBPmVbJwltGPqvQTSZFBCJeF1FXAjIZewQxUkVILzSS6hRxsw - Sqg+JDxYPahUcLx7dAO2Owmfh1v/gN02qlTPbo054YdLYON6H9wynvgL3mmr46oOqKKzKVwk52Fk - Dxljn+Mw23+6gg9u8FST26BNhnNeHv3g+hVXdrI4keRImRuVEP9T1S2S0ibezAvHhNr2Vwd+iTn2 - hLiLhEPdadtj8EEf1+58PSmny+WivBcNZIfsGwAA//8DAFj9bIN2AgAA - headers: - Connection: - - keep-alive - Content-Encoding: - - gzip - Content-Type: - - application/json - Date: Sun, 09 Jun 2024 23:39:08 GMT - Server: DUMMY - Transfer-Encoding: - - chunked - X-Content-Type-Options: - - nosniff - access-control-expose-headers: - - X-Request-ID - status: - code: 200 - message: OK -- request: - body: '{"messages": [{"content": "You are a helpful assistant that provides information - about movies.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. Don''t generate JSON until you are explicitly - told to. ", "role": "user"}, {"content": "Provide information about the movie - Shrek. It was released in 2001 and is an animation and comedy movie.", "role": - "user"}], "model": "gpt-4o-2024-08-06", "n": 1, "stream": false, "temperature": - 1.0}' - headers: - accept: - - application/json - accept-encoding: - - gzip, deflate - authorization: - - DUMMY - connection: - - keep-alive - content-length: - - '483' + - '328' content-type: - application/json host: @@ -360,36 +27,42 @@ interactions: method: POST uri: https://api.openai.com/v1/chat/completions response: - content: "{\n \"id\": \"chatcmpl-ABSmk0HtNNcFNhmhaovOzzWSL8oyy\",\n \"object\": - \"chat.completion\",\n \"created\": 1727295622,\n \"model\": \"gpt-4o-2024-08-06\",\n + content: "{\n \"id\": \"chatcmpl-ADHMu2BHeebjn5eFJBzts0kLqyTPz\",\n \"object\": + \"chat.completion\",\n \"created\": 1727728392,\n \"model\": \"gpt-4o-2024-08-06\",\n \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": - \"assistant\",\n \"content\": \"\\\"Shrek\\\" is a popular animated comedy - film released in 2001. Here is some information about the movie:\\n\\n**Title:** - Shrek \\n**Release Year:** 2001 \\n**Genre:** Animation, Comedy, Adventure, - Fantasy \\n**Directors:** Andrew Adamson and Vicky Jenson \\n**Production - Company:** DreamWorks Animation \\n**Main Voice Cast:**\\n - Mike Myers as - Shrek\\n - Eddie Murphy as Donkey\\n - Cameron Diaz as Princess Fiona\\n - - John Lithgow as Lord Farquaad\\n\\n**Plot Summary:** \\n\\\"Shrek\\\" is set - in a fairy tale world populated by various classic fairy tale characters. The - story follows Shrek, a reclusive and grumpy ogre who wants nothing more than - to live in peace in his swamp. However, his solitude is disrupted when numerous + \"assistant\",\n \"content\": \"\\\"Shrek\\\" is a 2001 animated fantasy-comedy + film produced by DreamWorks Animation and directed by Andrew Adamson and Vicky + Jenson. The film is loosely based on the 1990 fairy tale picture book of the + same name by William Steig.\\n\\n### Plot:\\nThe story follows Shrek, a reclusive + and grumpy ogre who lives in a swamp. His solitude is disrupted when numerous fairy tale creatures are exiled to his swamp by the evil Lord Farquaad. In order - to regain his privacy, Shrek makes a deal with Farquaad to rescue Princess Fiona - from a castle guarded by a dragon, so that Farquaad can marry her and become - king. Along the way, Shrek is joined by a talkative and humorous donkey named - Donkey, and together they embark on a journey that leads to unexpected friendships - and self-discovery.\\n\\n**Critical Reception:** \\nThe film was widely praised - for its witty humor, unique animation style, and subversion of traditional fairy - tale tropes. It was a major success both commercially and critically, grossing - over $480 million worldwide. \\\"Shrek\\\" won the first-ever Academy Award - for Best Animated Feature and remains a beloved classic in the animation genre.\\n\\n**Impact:** - \ \\n\\\"Shrek\\\" has spawned several sequels, spin-offs, and a Broadway musical. - It is often credited with revitalizing the animation industry and has had a - lasting impact on popular culture, inspiring countless memes and references.\",\n - \ \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": - \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 76,\n \"completion_tokens\": - 382,\n \"total_tokens\": 458,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": - 0\n }\n },\n \"system_fingerprint\": \"fp_7568d46099\"\n}\n" + to regain his peaceful life, Shrek agrees to rescue the beautiful Princess Fiona + for Farquaad, who wants to marry her to become king. Shrek is accompanied by + a talkative donkey named Donkey, and as they venture to save the princess, Shrek + discovers that Fiona has a secret.\\n\\n### Characters:\\n- **Shrek (voiced + by Mike Myers)**: The main protagonist, a grouchy yet good-hearted ogre.\\n- + **Princess Fiona (voiced by Cameron Diaz)**: A princess with a mysterious secret, + whom Shrek is tasked to rescue.\\n- **Donkey (voiced by Eddie Murphy)**: A chatty + and energetic donkey who becomes Shrek's loyal sidekick.\\n- **Lord Farquaad + (voiced by John Lithgow)**: The main antagonist, a diminutive and tyrannical + ruler.\\n\\n### Themes:\\n\\\"Shrek\\\" is known for its subversion of traditional + fairy tale tropes and its humorous approach, offering a fresh take on the story + by blending parody with adventure. The film also addresses themes of acceptance, + love, and the importance of looking beyond appearances.\\n\\n### Reception:\\nUpon + its release, \\\"Shrek\\\" was praised for its animation, creativity, voice + performances, and humor. It was both a critical and commercial success. The + film won the first-ever Academy Award for Best Animated Feature and was also + nominated for Best Adapted Screenplay.\\n\\n### Legacy:\\n\\\"Shrek\\\" became + a cultural phenomenon and led to several sequels and spin-offs, including \\\"Shrek + 2\\\" (2004), \\\"Shrek the Third\\\" (2007), and \\\"Shrek Forever After\\\" + (2010). The character of Shrek became iconic, and the film's success contributed + significantly to the popularity of DreamWorks Animation.\\n\\nOverall, \\\"Shrek\\\" + remains a beloved classic, known for its appeal to both children and adults, + due to its witty dialogue, memorable characters, and engaging story.\",\n \"refusal\": + null\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n + \ }\n ],\n \"usage\": {\n \"prompt_tokens\": 45,\n \"completion_tokens\": + 494,\n \"total_tokens\": 539,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": + 0\n }\n },\n \"system_fingerprint\": \"fp_e5e4913e83\"\n}\n" headers: Connection: - keep-alive @@ -409,38 +82,42 @@ interactions: status_code: 200 - request: body: '{"messages": [{"content": "You are a helpful assistant that provides information - about movies.", "role": "system"}, {"content": "In the last step of this chat - you will be asked to respond in JSON. Don''t generate JSON until you are explicitly - told to. ", "role": "user"}, {"content": "Provide information about the movie - Shrek. It was released in 2001 and is an animation and comedy movie.", "role": - "user"}, {"content": "\"Shrek\" is a popular animated comedy film released in - 2001. Here is some information about the movie:\n\n**Title:** Shrek \n**Release - Year:** 2001 \n**Genre:** Animation, Comedy, Adventure, Fantasy \n**Directors:** - Andrew Adamson and Vicky Jenson \n**Production Company:** DreamWorks Animation \n**Main - Voice Cast:**\n - Mike Myers as Shrek\n - Eddie Murphy as Donkey\n - Cameron - Diaz as Princess Fiona\n - John Lithgow as Lord Farquaad\n\n**Plot Summary:** \n\"Shrek\" - is set in a fairy tale world populated by various classic fairy tale characters. - The story follows Shrek, a reclusive and grumpy ogre who wants nothing more - than to live in peace in his swamp. However, his solitude is disrupted when - numerous fairy tale creatures are exiled to his swamp by the evil Lord Farquaad. - In order to regain his privacy, Shrek makes a deal with Farquaad to rescue Princess - Fiona from a castle guarded by a dragon, so that Farquaad can marry her and - become king. Along the way, Shrek is joined by a talkative and humorous donkey - named Donkey, and together they embark on a journey that leads to unexpected - friendships and self-discovery.\n\n**Critical Reception:** \nThe film was widely - praised for its witty humor, unique animation style, and subversion of traditional - fairy tale tropes. It was a major success both commercially and critically, - grossing over $480 million worldwide. \"Shrek\" won the first-ever Academy Award - for Best Animated Feature and remains a beloved classic in the animation genre.\n\n**Impact:** \n\"Shrek\" - has spawned several sequels, spin-offs, and a Broadway musical. It is often - credited with revitalizing the animation industry and has had a lasting impact - on popular culture, inspiring countless memes and references.", "role": "assistant"}, - {"content": "Use the information gathered in the conversation to answer.", "role": - "user"}], "model": "gpt-4o-2024-08-06", "n": 1, "response_format": {"type": - "json_schema", "json_schema": {"name": "OutputSchema", "description": "dict() - -> new empty dictionary\ndict(mapping) -> new dictionary initialized from a - mapping object''s\n (key, value) pairs\ndict(iterable) -> new dictionary - initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] + about movies.\nUse the chat history to produce a JSON output.", "role": "system"}, + {"content": "Provide information about the movie Shrek. It was released in 2001 + and is an animation and comedy movie.", "role": "user"}, {"content": "\"Shrek\" + is a 2001 animated fantasy-comedy film produced by DreamWorks Animation and + directed by Andrew Adamson and Vicky Jenson. The film is loosely based on the + 1990 fairy tale picture book of the same name by William Steig.\n\n### Plot:\nThe + story follows Shrek, a reclusive and grumpy ogre who lives in a swamp. His solitude + is disrupted when numerous fairy tale creatures are exiled to his swamp by the + evil Lord Farquaad. In order to regain his peaceful life, Shrek agrees to rescue + the beautiful Princess Fiona for Farquaad, who wants to marry her to become + king. Shrek is accompanied by a talkative donkey named Donkey, and as they venture + to save the princess, Shrek discovers that Fiona has a secret.\n\n### Characters:\n- + **Shrek (voiced by Mike Myers)**: The main protagonist, a grouchy yet good-hearted + ogre.\n- **Princess Fiona (voiced by Cameron Diaz)**: A princess with a mysterious + secret, whom Shrek is tasked to rescue.\n- **Donkey (voiced by Eddie Murphy)**: + A chatty and energetic donkey who becomes Shrek''s loyal sidekick.\n- **Lord + Farquaad (voiced by John Lithgow)**: The main antagonist, a diminutive and tyrannical + ruler.\n\n### Themes:\n\"Shrek\" is known for its subversion of traditional + fairy tale tropes and its humorous approach, offering a fresh take on the story + by blending parody with adventure. The film also addresses themes of acceptance, + love, and the importance of looking beyond appearances.\n\n### Reception:\nUpon + its release, \"Shrek\" was praised for its animation, creativity, voice performances, + and humor. It was both a critical and commercial success. The film won the first-ever + Academy Award for Best Animated Feature and was also nominated for Best Adapted + Screenplay.\n\n### Legacy:\n\"Shrek\" became a cultural phenomenon and led to + several sequels and spin-offs, including \"Shrek 2\" (2004), \"Shrek the Third\" + (2007), and \"Shrek Forever After\" (2010). The character of Shrek became iconic, + and the film''s success contributed significantly to the popularity of DreamWorks + Animation.\n\nOverall, \"Shrek\" remains a beloved classic, known for its appeal + to both children and adults, due to its witty dialogue, memorable characters, + and engaging story.", "role": "assistant"}, {"content": "Use the chat history + to produce a JSON output.", "role": "user"}], "model": "gpt-4o-2024-08-06", + "n": 1, "response_format": {"type": "json_schema", "json_schema": {"name": "OutputSchema", + "description": "dict() -> new empty dictionary\ndict(mapping) -> new dictionary + initialized from a mapping object''s\n (key, value) pairs\ndict(iterable) + -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] = v\ndict(**kwargs) -> new dictionary initialized with the name=value pairs\n in the keyword argument list. For example: dict(one=1, two=2)", "strict": true, "schema": {"type": "object", "properties": {"title": {"type": "string"}, "year": @@ -457,7 +134,7 @@ interactions: connection: - keep-alive content-length: - - '3086' + - '3419' content-type: - application/json host: @@ -471,14 +148,14 @@ interactions: method: POST uri: https://api.openai.com/v1/chat/completions response: - content: "{\n \"id\": \"chatcmpl-ABSmrCMkpNGStV1GdHXqpAbsLMerX\",\n \"object\": - \"chat.completion\",\n \"created\": 1727295629,\n \"model\": \"gpt-4o-2024-08-06\",\n + content: "{\n \"id\": \"chatcmpl-ADHMzgFZirDNsMRyXRrSbmSijnKJg\",\n \"object\": + \"chat.completion\",\n \"created\": 1727728397,\n \"model\": \"gpt-4o-2024-08-06\",\n \ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"{\\\"title\\\":\\\"Shrek\\\",\\\"year\\\":2001,\\\"genres\\\":[\\\"Animation\\\",\\\"Comedy\\\"]}\",\n \ \"refusal\": null\n },\n \"logprobs\": null,\n \"finish_reason\": - \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 620,\n \"completion_tokens\": - 18,\n \"total_tokens\": 638,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": - 0\n }\n },\n \"system_fingerprint\": \"fp_5050236cbd\"\n}\n" + \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 711,\n \"completion_tokens\": + 18,\n \"total_tokens\": 729,\n \"completion_tokens_details\": {\n \"reasoning_tokens\": + 0\n }\n },\n \"system_fingerprint\": \"fp_9e15ccd6a4\"\n}\n" headers: Connection: - keep-alive