A framework-free, first-principles implementation of an autonomous real-time weather agent loop utilizing Groq and LLaMA 3.3-70B.
Most modern AI applications abstract away core reasoning loops inside heavy third-party orchestration wrappers like LangChain or LangGraph. While convenient, this often obscures the underlying mechanics of context logging and model interaction.
NativeWeather-Agent completely eliminates this abstraction layer. Built entirely from scratch using native Python dictionaries, standard requests pipelines, and native Groq tool-calling schemas, this repository serves as a portfolio piece proving deep understanding of state log manipulation, autonomous runtime loops, routing logic, and dynamic tool dependencies.
The agent natively resolves complex, multi-turn tool dependency cycles. For example, when processing a query like: "What is the weather in Bathinda right now?", the agent executes a sequential workflow completely decoupled from hardcoded logic:
- Reasoning Step: Analyzes the query, recognizes a lack of real-time spatial knowledge, and schedules
get_coordinates. - Context Logging: Appends the assistant's tool-call intent into the persistent message state array.
- Dynamic Injection: Executes the native geocoding API request and pipes the resulting latitude/longitude outputs straight into a subsequent evaluation.
- Tool Transition: Automatically triggers
get_weatherwith the freshly parsed coordinates. - Synthesis: Grounds the finalized real-time meteorological vectors back into the LLM context window for a clean text summary.
- Zero Abstraction Bloat: Built using lightweight, native python dictionaries and native JSON schemas, maximizing inference tracking speed.
- Safe Attribute Reflection: Utilizes
getattr(message, "tool_calls", None)validation to gracefully intercept terminal non-tool responses from the model, eliminating standardNoneTypeattribute crashes. - Environment Isolation: Securely decouples API credentials from the code path using
python-dotenv.
- Inference Model: LLaMA-3.3-70b-versatile (via Groq API)
- Core Language: Python 3.10+
- External APIs: Open-Meteo Geocoding & Weather Forecast Engines
-
Clone the repository:
git clone [https://github.com/your-username/NativeWeather-Agent.git](https://github.com/your-username/NativeWeather-Agent.git) cd NativeWeather-Agent -
Install dependencies:
pip install -r requirements.txt
-
Set up your API key: Create a
.envfile in the root directory and add your Groq API key:GROQ_API_KEY=your_groq_api_key_here -
Run the agent:
python agent.py