Skip to content

Refactor tutorials #3

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

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

Conversation

venkateshpabbati
Copy link

No description provided.

venkateshpabbati and others added 3 commits May 5, 2025 09:42
This commit refactors the AI agent tutorial scripts in the repository to enhance clarity, robustness, adherence to best practices, and educational value.

Key changes include:

**Part 1: `1_phidata_finance_agent` Tutorials**

- Standardized Configuration: LLM model IDs are now configurable via environment variables (e.g., `GROQ_MODEL_ID`, `OPENAI_MODEL_ID`) with defaults. I added checks for API key presence (`GROQ_API_KEY`, `OPENAI_API_KEY`).
- Dependencies: I created `requirements.txt` for this set of tutorials.
- Enhanced `2_finance_agent_llama.py`: I improved the `get_company_symbol` tool by expanding the example dictionary and adding comments about using a proper API/database in real applications.
- Refined `3_agent_teams_openai.py`: I added detailed comments explaining how to switch between OpenAI and Groq models and clarified the agent team/delegation concept.
- General Code Quality: I added `try-except` blocks for agent API calls, improved comments for clarity, and ensured consistent formatting across all three finance agent scripts.

**Part 2: `2_mcp_leave_management` MCP Server Tutorial**

- Improved Project Metadata: I updated `pyproject.toml` with a more relevant name (`mcp_leave_management_tutorial`) and description.
- Database Refactoring: I replaced the in-memory Python dictionary with an SQLite database (`leave_management.db`).
    - I created `database.py` to handle all SQLite operations (connection, table creation, data initialization, CRUD operations for leave data).
    - I updated `main.py` to use `database.py` for all data persistence.
- Enhanced Tool Logic in `main.py`:
    - I significantly improved the `apply_leave` tool with comprehensive input validation for `leave_dates` (format, valid date values, past dates, already booked dates).
- General Code Quality:
    - I reviewed and improved `main.py` and `database.py` for clarity, adding module-level and inline comments, ensuring consistent type hinting, and updating docstrings.
    - I updated `README.md` in `2_mcp_leave_management/` to include information about the new SQLite database, its creation, and initialization.

I made all changes according to the established plan, and I conducted a final review of all modified files.
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