diff --git a/README.md b/README.md index 789a741..7b6eeaf 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -`uv run main.py` to run in dev container \ No newline at end of file +`uv run main.py` to run in dev container + +Might need to select interpreter in VS code and point to .venv directory \ No newline at end of file diff --git a/main.py b/main.py index b649634..4f48b80 100644 --- a/main.py +++ b/main.py @@ -2,13 +2,19 @@ import os from dotenv import load_dotenv from openai import OpenAI from openai.types.chat import ChatCompletionToolParam +from pydantic import BaseModel AGENT_1_PROMPT = "You are Agent 1, a curious assistant who asks thoughtful questions." AGENT_2_PROMPT = "You are Agent 2, a knowledgeable assistant who provides detailed answers." -MODEL = "gpt-4.1" +MODEL = "gpt-4o-mini" CONVERSATION_TURNS = 20 +class Response(BaseModel): + inner_thoughts: str + utterance: str + + class Agent: def __init__(self, client: OpenAI, message: str): self.client = client @@ -91,22 +97,21 @@ def main(): "strict": True, }) - response = client.responses.create( + response = client.responses.parse( model=MODEL, input=[ { "role": "system", - "content": "You are a helpful and curious assistant. Answer short and with a question so that the conversation continues" + "content": "You are a helpful and curious assistant. Answer short and with a question so that the conversation continues. When you answer use your inner thoughts and what you speak in the utterance. The utterance is what your chat partner can see. Your inner thoughts are only visible to you." }, { "role": "user", "content": "hey how is it going?" }], - tools=[tool] + text_format=Response ) - tool_call = response.output[0] - print("Response", tool_call) + print("Response", response.output_parsed.inner_thoughts) return diff --git a/pyproject.toml b/pyproject.toml index a8d4c3b..2c24c00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,5 +6,6 @@ readme = "README.md" requires-python = ">=3.12" dependencies = [ "openai>=1.68.2", + "pydantic>=2.10.6", "python-dotenv>=1.0.1", ] diff --git a/uv.lock b/uv.lock index 2ee77d5..1d27955 100644 --- a/uv.lock +++ b/uv.lock @@ -58,12 +58,14 @@ version = "0.1.0" source = { virtual = "." } dependencies = [ { name = "openai" }, + { name = "pydantic" }, { name = "python-dotenv" }, ] [package.metadata] requires-dist = [ { name = "openai", specifier = ">=1.68.2" }, + { name = "pydantic", specifier = ">=2.10.6" }, { name = "python-dotenv", specifier = ">=1.0.1" }, ]