Skip to content
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

description: > This pull request adds a new example to the crewAI-examples repository that demonstrates the use of the Ollama model and the DuckDuckGo search tool. changes_made: - file: ollama_examples/agent.py action: Added detail: > Includes a script to conduct research and write a blog post on Gradient Descent using crewAI, Ollama, and DuckDuckGo. - file: ollama_examples/README.md action: Created detail: Instructions on how to run the example. - file: examples/README.md action: Updated detail: Include the new ollama_examples section. notes: > This example shows how to: - Use the Ollama model for natural language understanding and generation. - Integrate DuckDuckGo search tool for web search capabilities. - Automate the research and writing process using crewAI. #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ By [@joaomdmoura](https://x.com/joaomdmoura).
- [Marketing Strategy](https://github.com/joaomdmoura/crewAI-examples/tree/main/marketing_strategy)
- [Surprise Trip](https://github.com/joaomdmoura/crewAI-examples/tree/main/surprise_trip)
- [Match to Proposal](https://github.com/joaomdmoura/crewAI-examples/tree/main/match_profile_to_positions)
- [Find Job Candidades Demo](https://github.com/joaomdmoura/crewAI-examples/tree/main/recruitment)


## Old Examples, need to be updated

Expand Down
8 changes: 8 additions & 0 deletions ollama_examples/REAME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ollama Examples

This folder contains examples of using the Ollama model with crewAI.

## Example: Gradient Descent Analysis

This example demonstrates how to use crewAI to automate the process of researching and writing a technical blog post on Gradient Descent.

76 changes: 76 additions & 0 deletions ollama_examples/local_research_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# importing the required modules
import logging
import os
from crewai import Agent, Task, Process, Crew
from dotenv import load_dotenv

# Load env variables
load_dotenv()

# Set up logging
logging.basicConfig(level=logging.INFO)

# DuckDuckGo arama aracını tanımlama
from langchain_community.tools import DuckDuckGoSearchRun
from langchain_community.llms import Ollama

ollama_openhermes = Ollama(model="openhermes")
ollama_llm = ollama_openhermes

# DuckDuckGo arama aracını tanımlama
search_tool = DuckDuckGoSearchRun()

# introduce the agents with their specific roles and goals
researcher = Agent(
role='Senior Research Analyst',
goal='Find out details regarding Gradient Descent',
backstory="""You are an expert in deep learning.
You are passionate about education.
You can explain complex concepts into simple terms.""",
verbose=True,
allow_delegation=False,
tools=[search_tool],
llm=ollama_llm
)

writer = Agent(
role='Technical Writer',
goal='Craft compelling content on Gradient Descent',
backstory="""You are a renowned Technical Writer, known for
your informative and insightful articles.
You transform complex concepts into compelling narratives.""",
verbose=True,
allow_delegation=True,
llm=ollama_llm
)

# Assigning the Tasks
# Create tasks for your agents
task1 = Task(
description="""Conduct a comprehensive analysis of Gradient Descent.
Identify key definitions and potential use-cases.
Your final answer MUST be a full analysis""",
agent=researcher,
expected_output=""
)

task2 = Task(
description="""Using the insights provided, develop a technical blog
post that highlights the most important aspects of Gradient Descent.
Your post should be informative yet accessible, catering to a tech-savvy audience.
Your final answer MUST be the full blog post of at least 4 paragraphs.""",
agent=writer,
expected_output=""
)

# Assemble the Crew
# Instantiate your crew with a sequential process
crew = Crew(
agents=[researcher, writer],
tasks=[task1, task2],
verbose=2
)

# Kick Things Off
result = crew.kickoff()
print(result)