Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AI-Powered Currency Conversion and Arithmetic with PydanticAI_Agnets_Custom_Tools_And_OpenAI_LLM #1720

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

05satyam
Copy link

@05satyam 05satyam commented Mar 14, 2025

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) and exchange_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:

  • I have added a new entry in registry.yaml (and, optionally, in authors.yaml) so that my content renders on the cookbook website.
  • I have conducted a self-review of my content based on the contribution guidelines:
    • Relevance: This content is related to building with OpenAI technologies and is useful to others.
    • 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.
    • Spelling and Grammar: I have checked for spelling or grammatical mistakes.
    • Clarity: I have done a final read-through and verified that my submission is well-organized and easy to understand.
    • Correctness: The information I include is correct and all of my code executes successfully.
    • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant