-
Notifications
You must be signed in to change notification settings - Fork 3.1k
My agent #183
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
LynAlinka
wants to merge
7
commits into
google-gemini:main
Choose a base branch
from
LynAlinka:my-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
My agent #183
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
be2c7b4
Refactor: Switched reasoning to llama-3.3-70b-versatile via Groq. Res…
LynAlinka 4af586b
Feature: Integrated local directory search via --dir parameter. Archi…
LynAlinka 207bd40
Final Refactor: Clean production-ready code for local .md documentati…
LynAlinka 9cc29f1
Fix: Optimized web_research with keyword matching for local docs
LynAlinka cb652b2
Fix: Add missing langchain-groq dependency and clean up project
LynAlinka 3e040bd
Refactor: web_research renamed to local_research
LynAlinka 648dd8e
Update prompts: focus on technical keywords for local research
LynAlinka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,44 @@ | ||
| import argparse | ||
| from langchain_core.messages import HumanMessage | ||
| import asyncio | ||
| import os | ||
| from dotenv import load_dotenv | ||
| from agent.graph import graph | ||
|
|
||
| load_dotenv() | ||
|
|
||
| def main() -> None: | ||
| """Run the research agent from the command line.""" | ||
| parser = argparse.ArgumentParser(description="Run the LangGraph research agent") | ||
| parser.add_argument("question", help="Research question") | ||
| async def main(): | ||
| # Setup command line arguments | ||
| parser = argparse.ArgumentParser(description="Local Research CLI") | ||
| parser.add_argument("topic", help="The topic to research") | ||
| parser.add_argument( | ||
| "--initial-queries", | ||
| type=int, | ||
| default=3, | ||
| help="Number of initial search queries", | ||
| ) | ||
| parser.add_argument( | ||
| "--max-loops", | ||
| type=int, | ||
| default=2, | ||
| help="Maximum number of research loops", | ||
| ) | ||
| parser.add_argument( | ||
| "--reasoning-model", | ||
| default="gemini-2.5-pro-preview-05-06", | ||
| help="Model for the final answer", | ||
| "--dir", | ||
| required=True, | ||
| help="Path to the local directory containing .md files for research" | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| state = { | ||
| "messages": [HumanMessage(content=args.question)], | ||
| "initial_search_query_count": args.initial_queries, | ||
| "max_research_loops": args.max_loops, | ||
| "reasoning_model": args.reasoning_model, | ||
| # Configure the graph with the local search directory | ||
| config = { | ||
| "configurable": { | ||
| "search_dir": args.dir, | ||
| "max_research_loops": 2 # Efficient looping for documentation analysis | ||
| } | ||
| } | ||
|
|
||
| result = graph.invoke(state) | ||
| messages = result.get("messages", []) | ||
| if messages: | ||
| print(messages[-1].content) | ||
| # Initialize the research with the user's topic | ||
| inputs = {"messages": [("user", args.topic)]} | ||
|
|
||
| print(f"Starting research in: {args.dir}") | ||
| print("-" * 30) | ||
|
|
||
| # Stream the results from the graph | ||
| async for event in graph.astream(inputs, config=config, stream_mode="values"): | ||
| message = event.get("messages") | ||
| if message: | ||
| if isinstance(message, list): | ||
| print(message[-1].content) | ||
| else: | ||
| print(message.content) | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| asyncio.run(main()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting for this
add_argumentcall is inconsistent with the others in this file and not well-aligned. For improved readability and consistency, please format it as a single line, similar to the other arguments.