Last active
November 28, 2024 12:17
-
-
Save onurhan1337/cf8a706059362bec100aecf8685a6eef to your computer and use it in GitHub Desktop.
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
| import os | |
| from crewai import Agent, Task, Crew, LLM, Process | |
| from crewai_tools import tool | |
| from langchain_community.tools import DuckDuckGoSearchRun | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| duckduckgo_search = DuckDuckGoSearchRun() | |
| api_key = os.getenv("GROQ_API_KEY") | |
| user_query = "Onurhan Demir work title and last company name" | |
| if not api_key: | |
| raise ValueError("API key is missing.") | |
| @tool('DuckDuckGoSearch') | |
| def search_tool(search_query: str): | |
| """Search the web for information on a given topic""" | |
| return duckduckgo_search.run(search_query) | |
| llm = LLM( | |
| model="groq/llama-3.1-8b-instant", | |
| api_key=api_key | |
| ) | |
| search_agent = Agent( | |
| role='Expert Researcher and Analyst', | |
| goal='Assist the user by processing and retrieving the most relevant information based on their query using a local model. Additionally, create research topics related to the subject and explore them in detail using English sources.', | |
| backstory="You are a senior researcher and analyst with a complete command of technical subjects. You enjoy researching and analyzing topics in depth, leveraging your expertise to create insightful summaries. You rely on English sources to ensure accuracy and thoroughness in your research.", | |
| tools=[perform_web_search], | |
| llm=llm, | |
| verbose=True, | |
| ) | |
| search_task = Task( | |
| description=f'Find and summarize the latest and most relevant news on "{user_query}". Create detailed research topics based on this subject and explore them comprehensively. Present the findings in a concise, clear, and informative manner, ensuring all key points are covered.', | |
| agent=search_agent, | |
| expected_output='A bullet list summary of the top 5 most important news related to the user query, including sources and key takeaways. Also, generate related research topics, each explored in detail, with actionable insights.' | |
| ) | |
| crew = Crew( | |
| agents=[search_agent], | |
| tasks=[search_task], | |
| process=Process.sequential, | |
| verbose=True, | |
| ) | |
| output = crew.kickoff() | |
| print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment