Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Oct 10, 2023
1 parent 95f569c commit 5d8e4d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion multi_agent_debate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from swarms.workers.worker import Worker
from langchain.llms import OpenAIChat

llm = OpenAIChat(model_name="gpt-4", openai_api_key="api-key", temperature=0.5)
llm = OpenAIChat()

worker1 = Worker(
llm=llm,
Expand Down
10 changes: 3 additions & 7 deletions swarms/workers/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
# cache
ROOT_DIR = "./data/"

# main
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]


class Worker:
"""
Expand Down Expand Up @@ -73,7 +70,7 @@ def __init__(
self.temperature = temperature
self.human_in_the_loop = human_in_the_loop
self.llm = llm
self.openai_api_key = openai_api_key or OPENAI_API_KEY
self.openai_api_key = openai_api_key
self.ai_name = ai_name
self.ai_role = ai_role
self.setup_tools(external_tools)
Expand Down Expand Up @@ -145,9 +142,8 @@ def setup_memory(self):
"""
Set up memory for the worker.
"""
openai_api_key = OPENAI_API_KEY
try:
embeddings_model = OpenAIEmbeddings(openai_api_key=openai_api_key)
embeddings_model = OpenAIEmbeddings(openai_api_key=self.openai_api_key)
embedding_size = 1536
index = faiss.IndexFlatL2(embedding_size)

Expand Down Expand Up @@ -283,4 +279,4 @@ def _message_to_dict(message: Union[Dict, str]):
if isinstance(message, str):
return {"content": message}
else:
return message
return message

0 comments on commit 5d8e4d5

Please sign in to comment.