forked from tylerprogramming/ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added crewai examples with gpt, lmstudio and ollama
- Loading branch information
1 parent
ef8e363
commit 1ca99e3
Showing
3 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from crewai import Agent, Task, Crew, Process | ||
|
||
os.environ["OPENAI_API_KEY"] = "sk-1111" | ||
|
||
# Create a researcher agent | ||
researcher = Agent( | ||
role='Senior Researcher', | ||
goal='Discover groundbreaking technologies', | ||
backstory='A curious mind fascinated by cutting-edge innovation and the potential to change the world, ' | ||
'you know everything about tech.', | ||
verbose=True, | ||
) | ||
|
||
# Create a writer agent | ||
writer = Agent( | ||
role='Writer', | ||
goal='Craft compelling stories about tech discoveries', | ||
backstory='A creative soul who translates complex tech jargon into engaging narratives for the masses, you write ' | ||
'using simple words in a friendly and inviting tone that does not sounds like AI.', | ||
verbose=True, | ||
) | ||
|
||
# Task for the researcher | ||
research_task = Task( | ||
description='Identify the next big trend in AI', | ||
agent=researcher # Assigning the task to the researcher | ||
) | ||
|
||
# Task for the writer | ||
write_task = Task( | ||
description='Write an article on AI advancements leveraging the research made.', | ||
agent=writer # Assigning the task to the writer | ||
) | ||
|
||
# Instantiate your crew with a sequential process | ||
tech_crew = Crew( | ||
agents=[researcher, writer], | ||
tasks=[research_task, write_task], | ||
process=Process.sequential, # Tasks will be executed one after the other | ||
) | ||
|
||
# Get your crew to work! | ||
print(tech_crew.agents) | ||
result = tech_crew.kickoff() | ||
|
||
print("######################") | ||
print(result) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
from crewai import Agent, Task, Crew, Process | ||
|
||
# either use api key for gpt, or just some string for local | ||
os.environ["OPENAI_API_KEY"] = "sk-1111" | ||
os.environ["OPENAI_API_BASE"] = "http://localhost:1234/v1" | ||
|
||
|
||
# Create a researcher agent | ||
researcher = Agent( | ||
role='Senior Researcher', | ||
goal='Discover groundbreaking technologies', | ||
backstory='A curious mind fascinated by cutting-edge innovation and the potential to change the world, ' | ||
'you know everything about tech.', | ||
verbose=True, | ||
) | ||
|
||
# Create a writer agent | ||
writer = Agent( | ||
role='Writer', | ||
goal='Craft compelling stories about tech discoveries', | ||
verbose=True, | ||
backstory='A creative soul who translates complex tech jargon into engaging narratives for the masses, you write ' | ||
'using simple words in a friendly and inviting tone that does not sounds like AI.', | ||
) | ||
|
||
# Task for the researcher | ||
research_task = Task( | ||
description='Identify the next big trend in AI', | ||
agent=researcher # Assigning the task to the researcher | ||
) | ||
|
||
# Task for the writer | ||
write_task = Task( | ||
description='Write an article on AI advancements leveraging the research made.', | ||
agent=writer # Assigning the task to the writer | ||
) | ||
|
||
# Instantiate your crew with a sequential process | ||
tech_crew = Crew( | ||
agents=[researcher, writer], | ||
tasks=[research_task, write_task], | ||
process=Process.sequential, # Tasks will be executed one after the other | ||
) | ||
|
||
# Get your crew to work! | ||
result = tech_crew.kickoff() | ||
|
||
print("######################") | ||
print(result) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
from crewai import Agent, Task, Crew, Process | ||
from langchain.llms import Ollama | ||
|
||
# used for Ollama and a local model | ||
ollama_openhermes = Ollama(model="openhermes") | ||
|
||
# either use api key for gpt, or just some string for local | ||
os.environ["OPENAI_API_KEY"] = "sk-1111" | ||
|
||
|
||
# Create a researcher agent | ||
researcher = Agent( | ||
role='Senior Researcher', | ||
goal='Discover groundbreaking technologies', | ||
backstory='A curious mind fascinated by cutting-edge innovation and the potential to change the world, ' | ||
'you know everything about tech.', | ||
verbose=True, | ||
llm=ollama_openhermes | ||
) | ||
|
||
# Create a writer agent | ||
writer = Agent( | ||
role='Writer', | ||
goal='Craft compelling stories about tech discoveries', | ||
verbose=True, | ||
backstory='A creative soul who translates complex tech jargon into engaging narratives for the masses, you write ' | ||
'using simple words in a friendly and inviting tone that does not sounds like AI.', | ||
llm=ollama_openhermes | ||
) | ||
|
||
# Task for the researcher | ||
research_task = Task( | ||
description='Identify the next big trend in AI', | ||
agent=researcher # Assigning the task to the researcher | ||
) | ||
|
||
# Task for the writer | ||
write_task = Task( | ||
description='Write an article on AI advancements leveraging the research made.', | ||
agent=writer # Assigning the task to the writer | ||
) | ||
|
||
# Instantiate your crew with a sequential process | ||
tech_crew = Crew( | ||
agents=[researcher, writer], | ||
tasks=[research_task, write_task], | ||
process=Process.sequential, # Tasks will be executed one after the other | ||
llm=ollama_openhermes | ||
) | ||
|
||
# Get your crew to work! | ||
result = tech_crew.kickoff() | ||
|
||
print("######################") | ||
print(result) |