diff --git a/python/samples/getting_started/agents/openai_assistants_client/openai_assistants_basic.py b/python/samples/getting_started/agents/openai_assistants_client/openai_assistants_basic.py deleted file mode 100644 index 65b7fb0991..0000000000 --- a/python/samples/getting_started/agents/openai_assistants_client/openai_assistants_basic.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) Microsoft. All rights reserved. - -import asyncio -from random import randint -from typing import Annotated - -from agent_framework import ChatClientAgent -from agent_framework.openai import OpenAIAssistantsClient -from pydantic import Field - - -def get_weather( - location: Annotated[str, Field(description="The location to get the weather for.")], -) -> str: - """Get the weather for a given location.""" - conditions = ["sunny", "cloudy", "rainy", "stormy"] - return f"The weather in {location} is {conditions[randint(0, 3)]} with a high of {randint(10, 30)}°C." - - -async def non_streaming_example() -> None: - """Example of non-streaming response (get the complete result at once).""" - print("=== Non-streaming Response Example ===") - - # Since no assistant ID is provided, the assistant will be automatically created - # and deleted after getting a response - async with ChatClientAgent( - chat_client=OpenAIAssistantsClient(), - instructions="You are a helpful weather agent.", - tools=get_weather, - ) as agent: - query = "What's the weather like in Seattle?" - print(f"User: {query}") - result = await agent.run(query) - print(f"Agent: {result}\n") - - -async def streaming_example() -> None: - """Example of streaming response (get results as they are generated).""" - print("=== Streaming Response Example ===") - - # Since no assistant ID is provided, the assistant will be automatically created - # and deleted after getting a response - async with ChatClientAgent( - chat_client=OpenAIAssistantsClient(), - instructions="You are a helpful weather agent.", - tools=get_weather, - ) as agent: - query = "What's the weather like in Portland?" - print(f"User: {query}") - print("Agent: ", end="", flush=True) - async for chunk in agent.run_stream(query): - if chunk.text: - print(chunk.text, end="", flush=True) - print("\n") - - -async def main() -> None: - print("=== Basic OpenAI Assistants Chat Client Agent Example ===") - - await non_streaming_example() - await streaming_example() - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/python/samples/getting_started/agents/openai_assistants_client/openai_assistants_with_code_interpreter.py b/python/samples/getting_started/agents/openai_assistants_client/openai_assistants_with_code_interpreter.py deleted file mode 100644 index 916b05c19f..0000000000 --- a/python/samples/getting_started/agents/openai_assistants_client/openai_assistants_with_code_interpreter.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) Microsoft. All rights reserved. - -import asyncio - -from agent_framework import AgentRunResponseUpdate, ChatClientAgent, HostedCodeInterpreterTool -from agent_framework.openai import OpenAIAssistantsClient -from openai.types.beta.threads.runs import ( - CodeInterpreterToolCallDelta, - RunStepDelta, - RunStepDeltaEvent, - ToolCallDeltaObject, -) -from openai.types.beta.threads.runs.code_interpreter_tool_call_delta import CodeInterpreter - - -def get_code_interpreter_chunk(chunk: AgentRunResponseUpdate) -> str | None: - """Helper method to access code interpreter data.""" - if ( - isinstance(chunk.raw_representation, RunStepDeltaEvent) - and isinstance(chunk.raw_representation.delta, RunStepDelta) - and isinstance(chunk.raw_representation.delta.step_details, ToolCallDeltaObject) - and chunk.raw_representation.delta.step_details.tool_calls - ): - for tool_call in chunk.raw_representation.delta.step_details.tool_calls: - if ( - isinstance(tool_call, CodeInterpreterToolCallDelta) - and isinstance(tool_call.code_interpreter, CodeInterpreter) - and tool_call.code_interpreter.input is not None - ): - return tool_call.code_interpreter.input - return None - - -async def main() -> None: - """Example showing how to use the HostedCodeInterpreterTool with OpenAI Assistants.""" - print("=== OpenAI Assistants Agent with Code Interpreter Example ===") - - async with ChatClientAgent( - chat_client=OpenAIAssistantsClient(), - instructions="You are a helpful assistant that can write and execute Python code to solve problems.", - tools=HostedCodeInterpreterTool(), - ) as agent: - query = "What is current datetime?" - print(f"User: {query}") - print("Agent: ", end="", flush=True) - generated_code = "" - async for chunk in agent.run_stream(query): - if chunk.text: - print(chunk.text, end="", flush=True) - code_interpreter_chunk = get_code_interpreter_chunk(chunk) - if code_interpreter_chunk is not None: - generated_code += code_interpreter_chunk - - print(f"\nGenerated code:\n{generated_code}") - - -if __name__ == "__main__": - asyncio.run(main())