@ -45,14 +45,18 @@ from swarms.workers import Worker
from swarms.swarms import MultiAgentDebate, select_speaker
from swarms.models import OpenAIChat
api_key = "sk-"
llm = OpenAIChat(
model_name='gpt-4',
openai_api_key="api-key",
openai_api_key=api_key,
temperature=0.5
)
node = Worker(
llm=llm,
openai_api_key=api_key,
ai_name="Optimus Prime",
ai_role="Worker in a swarm",
external_tools = None,
@ -62,6 +66,7 @@ node = Worker(
node2 = Worker(
llm=llm,
openai_api_key=api_key,
ai_name="Bumble Bee",
ai_role="Worker in a swarm",
external_tools = None,
@ -71,6 +76,7 @@ node2 = Worker(
node3 = Worker(
llm=llm,
openai_api_key=api_key,
ai_name="Bumble Bee",
ai_role="Worker in a swarm",
external_tools = None,
@ -104,30 +110,31 @@ for result in results:
- And, then place the openai api key in the Worker for the openai embedding model
```python
from swarms.models import ChatOpenAI
from swarms.workers import Worker
from swarms.models import OpenAIChat
from swarms import Worker
llm = ChatOpenAI(
model_name='gpt-4',
openai_api_key="api-key",
temperature=0.5
api_key = ""
llm = OpenAIChat(
openai_api_key=api_key,
temperature=0.5,
)
node = Worker(
llm=llm,
ai_name="Optimus Prime",
#openai key for the embeddings
openai_api_key="sk-eee"
openai_api_key=api_key,
ai_role="Worker in a swarm",
external_tools=None,
human_in_the_loop=False,
temperature=0.5,
external_tools=None,
human_in_the_loop=False,
temperature=0.5,
)
task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times."