openai-cookbook
openai-cookbook copied to clipboard
Adding AI-Powered Currency Conversion and Arithmetic with PydanticAI_Agnets_Custom_Tools_And_OpenAI_LLM
OpenAI LLM based agentic implementation using Pydantic-Agents & Custom Tools implementation
📌 Summary
This PR introduces an implementation of Pyndantic AI Agents & Tools using OpenAI's models. It provides a structured approach to executing function calls, integrating external tools, and leveraging AI-driven decision-making. The content includes well-documented examples demonstrating the calculate and currency exchange tools within an agent-based workflow.
Key Additions:
- Function tools: Implements
calculate(arithmetic operations) andexchange_currency(currency conversion). - Agent integration: Uses OpenAI models to handle user queries efficiently.
- Example use case: Multi-step queries where the agent can invoke the appropriate tool dynamically.
- Error handling & best practices: Ensures robust input validation, response parsing, and API reliability.
Motivation
This addition enhances the OpenAI Cookbook by providing:
- Practical Examples: Demonstrates how to extend LLM capabilities with external tools and specifically on how to build agents with PyndanticAI and OpenAI together.
- Real-world Use Cases: Covers function calling, structured outputs, and agent routing.
- Best Practices: Implements guardrails, error handling, and optimized prompt engineering.
- Expands the Cookbook: Addresses a gap in multi-tool agent interactions with PyndanticAI- a framework used widely among the community.
For new content
When contributing new content, read through our contribution guidelines, and mark the following action items as completed:
- [x] I have added a new entry in registry.yaml (and, optionally, in authors.yaml) so that my content renders on the cookbook website.
- [x] I have conducted a self-review of my content based on the contribution guidelines:
- [x] Relevance: This content is related to building with OpenAI technologies and is useful to others.
- [x] Uniqueness: I have searched for related examples in the OpenAI Cookbook, and verified that my content offers new insights or unique information compared to existing documentation.
- [x] Spelling and Grammar: I have checked for spelling or grammatical mistakes.
- [x] Clarity: I have done a final read-through and verified that my submission is well-organized and easy to understand.
- [x] Correctness: The information I include is correct and all of my code executes successfully.
- [x] Completeness: I have explained everything fully, including all necessary references and citations.
We will rate each of these areas on a scale from 1 to 4, and will only accept contributions that score 3 or higher on all areas. Refer to our contribution guidelines for more details.
📌 Notes for Reviewers
- Let me know if any modifications or refinements are required.
- I am open to feedback and will address any suggested improvements promptly.
- Thank you for reviewing this contribution!
- Satyam Mittal