Skip to content

vins13pattar/Python-for-Gen-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python for Gen AI

A hands-on learning workspace for Python fundamentals and the building blocks commonly used in Gen AI apps (HTTP clients, FastAPI, Pydantic, notebooks).

Repository map

  • 1_python_basics/: Core Python (types, strings, collections, control flow, functions, files, exceptions, OOP, decorators).
  • 2_packages/: A tiny package + unit tests (good for learning imports + tests).
  • 3_fastapi/: A small FastAPI app demonstrating common API patterns.
  • 4_requests_basics/: Runnable requests examples (auth, retries, sessions).
  • 5_basic_pydantic/: Pydantic basics + a few advanced patterns.
  • 6_httpx_basics/: httpx sync/async/streaming patterns, plus LLM-style examples.
  • 7_jupyter_notebook/: Notebook(s) for interactive exploration.
  • projects/: Larger "projects" sample projects (complete mini-apps you can run end-to-end).

Projects

Smart Study Assistant (projects/smart-study-assistant/)

Multi-role CLI assistant that routes tasks between OpenAI / Gemini / Claude based on the query type/complexity.

cd "projects/smart-study-assistant"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Set at least one API key (recommended: use a local .env file)
# OPENAI_API_KEY=...
# GEMINI_API_KEY=...
# ANTHROPIC_API_KEY=...

python main.py chat

Smart Study Assistant Simple (projects/smart-study-assistant-simple/)

A streamlined version of the Smart Study Assistant, focusing on core logic.

cd "projects/smart-study-assistant-simple"
# ... setup steps similar to above ...

Function Calling: Weather (projects/function_calling/)

Small demo showing OpenAI tool/function calling that fetches current weather from OpenWeatherMap (city name or ZIP+country).

cd "projects/function_calling"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Create a .env file (see env.example)
# OPENAI_API_KEY=...
# WEATHER_API_KEY=...

python main.py

FAQ RAG System (projects/faq-rag-system/)

A Retrieval-Augmented Generation (RAG) system for answering FAQs interactive CLI, supporting OpenAI and local embeddings (Sentence Transformers).

cd "projects/faq-rag-system"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Create .env with OPENAI_API_KEY if using OpenAI
# Or use local embeddings (see README)

python main.py

LLM API Wrapper (projects/llm-api-wrapper/)

Unified wrapper for multiple LLM providers.

cd "projects/llm-api-wrapper"
# ... setup steps ...

Setup (recommended)

Create a virtual environment per module (each folder may have its own requirements.txt).

# From this repo root
cd "3_fastapi"  # or 4_requests_basics / 6_httpx_basics / ...

python3 -m venv .venv
source .venv/bin/activate

pip install -r requirements.txt  # if this module has one

Run examples

Python scripts

python3 1_python_basics/1_print_functions.py
python3 4_requests_basics/01_get_json.py
python3 6_httpx_basics/01_httpx-basics.py

FastAPI

cd "3_fastapi"
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

uvicorn main:app --reload

Then open:

  • Docs: http://127.0.0.1:8000/docs
  • Health: http://127.0.0.1:8000/health

Notes

  • Internet required for many HTTP examples (requests/httpx).
  • API keys: if you run any LLM/OpenAI-style examples, prefer environment variables (e.g. OPENAI_API_KEY) and keep secrets out of git.

About

A hands-on learning workspace for Python fundamentals and the building blocks commonly used in Gen AI apps (HTTP clients, FastAPI, Pydantic, notebooks).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors