Overview
- Project: Agentic_AI — collection of small examples demonstrating LangChain runnables, tools, and agent patterns.
- Environment: Uses a
.envfile for API keys. Required keys:OPENWEATHER_API_KEY,TAVILY_API_KEY.
File Notes
- Agents.py: Implements an interactive "city assistant" agent with two tools: get_weather and get_news. Uses
TavilyClientfor news andChatMistralAIas the LLM. Includes a human-approval middleware that prompts before each tool call. Known issue: requires thelangchain-mistralaipackage (import may raise ModuleNotFoundError if not installed). - main.py: Minimal entrypoint printing a greeting. Useful as a quick smoke-run:
python main.py. - newssummarizer.py: Runs a Tavily search (
TavilySearchResults) then passes results through aChatMistralAIprompt to produce a summarized bullet list. - owntool.py: Example of defining a LangChain
@tool(get_greeting) and invoking it locally. Prints tool metadata (name,description,args). - parallelrunnable.py: Demonstrates
RunnableParallelto run short and long explanations in parallel usingRunnableLambda,ChatPromptTemplate, andChatMistralAI. - runnablepassthrough.py: Shows
RunnablePassthroughcombined with a code-generation prompt and an explanation prompt; composes runnables and prints both code and explanation outputs. - sequencerunnable.py: Simple
prompt | model | parsersequence usingChatMistralAIandStrOutputParser. - toolcalling.py: Interactive example where an LLM binds to a tool (
get_text_length) and the script handles tool-calls and final responses. - streamlit_app.py: Streamlit web UI for fetching weather or news by city using the same API workflows and
.envkeys.
How to run
- Create and activate a virtual environment (Windows PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txt- Add a
.envfile with the required API keys:
OPENWEATHER_API_KEY=your_openweather_key
TAVILY_API_KEY=your_tavily_key
- Run an example, for instance the agent:
python {filename}.py- Run the Streamlit interface:
streamlit run streamlit_app.py