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

updates to ollama setup required for running local models #75

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions game-builder-crew/agents.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import os

from langchain_openai.chat_models import ChatOpenAI
from textwrap import dedent
from crewai import Agent

from dotenv import load_dotenv()
load_dotenv()

api_key = os.getenv("OPENAI_API_KEY")

class GameAgents():
def __init__(self):
self.llm = ChatOpenAI(api_key = api_key)

def senior_engineer_agent(self):
return Agent(
role='Senior Software Engineer',
Expand All @@ -11,6 +22,7 @@ def senior_engineer_agent(self):
Your expertise in programming in python. and do your best to
produce perfect code"""),
allow_delegation=False,
llm= self.llm,
verbose=True
)

Expand All @@ -26,7 +38,8 @@ def qa_engineer_agent(self):
brackets and syntax errors.
You also check for security vulnerabilities, and logic errors"""),
allow_delegation=False,
verbose=True
verbose=True,
llm = self.llm
)

def chief_qa_engineer_agent(self):
Expand All @@ -37,5 +50,6 @@ def chief_qa_engineer_agent(self):
You feel that programmers always do only half the job, so you are
super dedicate to make high quality code."""),
allow_delegation=True,
verbose=True
verbose=True,
llm = self.llm
)
3 changes: 3 additions & 0 deletions game-builder-crew/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def code_task(self, agent, game):

Your Final answer must be the full python code, only the python code and nothing else.
"""),
expected_output="Full python code of required function",
agent=agent
)

Expand All @@ -28,6 +29,7 @@ def review_task(self, agent, game):

Your Final answer must be the full python code, only the python code and nothing else.
"""),
expected_output= "Fully functional python code of the required functions",
agent=agent
)

Expand All @@ -44,5 +46,6 @@ def evaluate_task(self, agent, game):

Your Final answer must be the full python code, only the python code and nothing else.
"""),
expected_output= "Fully functional code of the required function",
agent=agent
)
3 changes: 2 additions & 1 deletion instagram_post/tools/browser_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def scrape_and_summarize_website(website):
task = Task(
agent=agent,
description=
f'Analyze and make a LONG summary the content bellow, make sure to include the ALL relevant information in the summary, return only the summary nothing else.\n\nCONTENT\n----------\n{chunk}'
f'Analyze and make a LONG summary the content bellow, make sure to include the ALL relevant information in the summary, return only the summary nothing else.\n\nCONTENT\n----------\n{chunk}',
expected_output= "A detailed summary of the content"
)
summary = task.execute()
summaries.append(summary)
Expand Down
13 changes: 11 additions & 2 deletions job-posting/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import os

from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")


from crewai import Crew
from crewai import Crew, Process
from langchain_openai.chat_models import ChatOpenAI

from tasks import Tasks
from agents import Agents

tasks = Tasks()
agents = Agents()

llm = ChatOpenAI(api_key=api_key)

company_description = input("What is the company description?\n")
company_domain = input("What is the company domain?\n")
hiring_needs = input("What are the hiring needs?\n")
Expand All @@ -35,7 +42,9 @@
research_role_requirements_task,
draft_job_posting_task,
review_and_edit_job_posting_task
]
],
process = Process.sequential,
manager_llm = llm
)

# Kick off the process
Expand Down
44 changes: 34 additions & 10 deletions landing_page_generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import shutil
from textwrap import dedent

from crewai import Agent, Crew, Task
from langchain_openai.chat_models import ChatOpenAI
from langchain_community.chat_models import ChatOllama
from crewai import Agent, Crew, Task, Process
from langchain.agents.agent_toolkits import FileManagementToolkit
from tasks import TaskPrompts

Expand All @@ -15,11 +17,14 @@
from dotenv import load_dotenv
load_dotenv()

api_key = os.getenv("OPENAI_API_KEY")

class LandingPageCrew():
def __init__(self, idea):
self.agents_config = json.loads(open("config/agents.json", "r").read())
self.idea = idea
self.__create_agents()
self.openai = ChatOpenAI(api_key= api_key)

def run(self):
expanded_idea = self.__expand_idea()
Expand All @@ -29,16 +34,20 @@ def run(self):
def __expand_idea(self):
expand_idea_task = Task(
description=TaskPrompts.expand().format(idea=self.idea),
expected_output="A detailed and correct output",
agent=self.idea_analyst
)
refine_idea_task = Task(
description=TaskPrompts.refine_idea(),
expected_output = "A detailed and correct output",
agent=self.communications_strategist
)
crew = Crew(
agents=[self.idea_analyst, self.communications_strategist],
tasks=[expand_idea_task, refine_idea_task],
verbose=True
verbose=True,
process = Process.sequential,
manager_llm = self.openai
)
expanded_idea = crew.kickoff()
return expanded_idea
Expand All @@ -48,18 +57,22 @@ def __choose_template(self, expanded_idea):
description=TaskPrompts.choose_template().format(
idea=self.idea
),
agent=self.react_developer
agent=self.react_developer,
expected_output = "A detailed and relevant output"
)
update_page = Task(
description=TaskPrompts.update_page().format(
idea=self.idea
),
agent=self.react_developer
agent=self.react_developer,
expected_output = " A detailed and correct output"
)
crew = Crew(
agents=[self.react_developer],
tasks=[choose_template_task, update_page],
verbose=True
verbose=True,
process = Process.sequential,
manager_llm = self.openai
)
components = crew.kickoff()
return components
Expand All @@ -79,25 +92,31 @@ def __update_components(self, components, expanded_idea):
file_content=file_content,
component=component
),
expected_output = "A detailed and correct output",
agent=self.content_editor_agent
)
update_component = Task(
description=TaskPrompts.update_component().format(
component=component,
file_content=file_content
),
expected_output = "A detailed and correct output"
agent=self.react_developer
)
qa_component = Task(
description=TaskPrompts.qa_component().format(
component=component
),
agent=self.react_developer
agent=self.react_developer,
expected_output= "A detailed and correct output"
)
crew = Crew(
agents=[self.content_editor_agent, self.react_developer],
tasks=[create_content, update_component, qa_component],
verbose=True
verbose=True,
process = Process.sequential,
manager_llm = self.openai

)
crew.kickoff()

Expand All @@ -118,7 +137,8 @@ def __create_agents(self):
tools=[
SearchTools.search_internet,
BrowserTools.scrape_and_summarize_website
]
],
llm = self.openai
)

self.communications_strategist = Agent(
Expand All @@ -127,27 +147,31 @@ def __create_agents(self):
tools=[
SearchTools.search_internet,
BrowserTools.scrape_and_summarize_website,
]
],
llm= self.openai
)

self.react_developer = Agent(
**developer_config,
verbose=True,
llm= self.openai,
tools=[
SearchTools.search_internet,
BrowserTools.scrape_and_summarize_website,
TemplateTools.learn_landing_page_options,
TemplateTools.copy_landing_page_template_to_project_folder,
FileTools.write_file
] + toolkit.get_tools()

)

self.content_editor_agent = Agent(
**editor_config,
tools=[
SearchTools.search_internet,
BrowserTools.scrape_and_summarize_website,
]
],
llm = self.openai
)

if __name__ == "__main__":
Expand Down
11 changes: 9 additions & 2 deletions landing_page_generator/tools/browser_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import requests
from crewai import Agent, Task
from langchain.tools import tool
from langchain_openai.chat_models import ChatOpenAI
from unstructured.partition.html import partition_html
from dotenv import load_dotenv
load_dotenv()

api_key = os.getenv('OPENAI_API_KEY')

class BrowserTools():

Expand All @@ -27,11 +31,14 @@ def scrape_and_summarize_website(website):
'Do amazing researches and summaries based on the content you are working with',
backstory=
"You're a Principal Researcher at a big company and you need to do a research about a given topic.",
allow_delegation=False)
allow_delegation=False,
llm = ChatOpenAI(api_key = api_key)
)
task = Task(
agent=agent,
description=
f'Analyze and summarize the content bellow, make sure to include the most relevant information in the summary, return only the summary nothing else.\n\nCONTENT\n----------\n{chunk}'
f'Analyze and summarize the content bellow, make sure to include the most relevant information in the summary, return only the summary nothing else.\n\nCONTENT\n----------\n{chunk}',
expected_output = "A detailed summary of the content"
)
summary = task.execute()
summaries.append(summary)
Expand Down
3 changes: 2 additions & 1 deletion markdown_validator/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from crewai import Agent, Task
from crewai import Agent, Task, Process
import os
from dotenv import load_dotenv
from langchain.tools import tool
Expand Down Expand Up @@ -70,6 +70,7 @@ def process_markdown_document(filename):

If you already know the answer or if you do not need
to use a tool, return it as your Final Answer.""",
expected_output = "Valid markdown script",
agent=general_agent)

updated_markdown = syntax_review_task.execute()
Expand Down
13 changes: 13 additions & 0 deletions ollama_setup/gemmaModelfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM gemma

# Set parementers

PARAMETER temperature 0.3
PARAMETER stop Result

# Sets a custom system message to specify the behavior of
# the chat assistant

# Leaving it blank for now.

SYSTEM """You are an expert in any required domain"""
13 changes: 13 additions & 0 deletions ollama_setup/gemma_crewai_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Variables
model_name="gemma"
custom_model_name="crewai-gemma"

# Get the base model
ollama pull $model_name

# Create the model file
ollama create $custom_model_name -f ./gemmaModelfile

# enter "chmod +x <filename>" to make file executable
13 changes: 13 additions & 0 deletions ollama_setup/llama2Modelfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM llama2

# Set parementers

PARAMETER temperature 0.3
PARAMETER stop Result

# Sets a custom system message to specify the behavior of
# the chat assistant

# Leaving it blank for now.

SYSTEM """You are an expert in any required domain"""
13 changes: 13 additions & 0 deletions ollama_setup/llama_crewai_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Variables
model_name="llama2"
custom_model_name="crewai-llama2"

# Get the base model
ollama pull $model_name

# Create the model file
ollama create $custom_model_name -f ./llama2Modelfile

# enter "chmod +x <filename>" to make file executable
13 changes: 13 additions & 0 deletions ollama_setup/mistralModelfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mistral

# Set parementers

PARAMETER temperature 0.3
PARAMETER stop Result

# Sets a custom system message to specify the behavior of
# the chat assistant

# Leaving it blank for now.

SYSTEM """You are an expert in any required domain"""
Loading