|
|
@ -45,14 +45,18 @@ from swarms.workers import Worker
|
|
|
|
from swarms.swarms import MultiAgentDebate, select_speaker
|
|
|
|
from swarms.swarms import MultiAgentDebate, select_speaker
|
|
|
|
from swarms.models import OpenAIChat
|
|
|
|
from swarms.models import OpenAIChat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_key = "sk-"
|
|
|
|
|
|
|
|
|
|
|
|
llm = OpenAIChat(
|
|
|
|
llm = OpenAIChat(
|
|
|
|
model_name='gpt-4',
|
|
|
|
model_name='gpt-4',
|
|
|
|
openai_api_key="api-key",
|
|
|
|
openai_api_key=api_key,
|
|
|
|
temperature=0.5
|
|
|
|
temperature=0.5
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
node = Worker(
|
|
|
|
node = Worker(
|
|
|
|
llm=llm,
|
|
|
|
llm=llm,
|
|
|
|
|
|
|
|
openai_api_key=api_key,
|
|
|
|
ai_name="Optimus Prime",
|
|
|
|
ai_name="Optimus Prime",
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
external_tools = None,
|
|
|
|
external_tools = None,
|
|
|
@ -62,6 +66,7 @@ node = Worker(
|
|
|
|
|
|
|
|
|
|
|
|
node2 = Worker(
|
|
|
|
node2 = Worker(
|
|
|
|
llm=llm,
|
|
|
|
llm=llm,
|
|
|
|
|
|
|
|
openai_api_key=api_key,
|
|
|
|
ai_name="Bumble Bee",
|
|
|
|
ai_name="Bumble Bee",
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
external_tools = None,
|
|
|
|
external_tools = None,
|
|
|
@ -71,6 +76,7 @@ node2 = Worker(
|
|
|
|
|
|
|
|
|
|
|
|
node3 = Worker(
|
|
|
|
node3 = Worker(
|
|
|
|
llm=llm,
|
|
|
|
llm=llm,
|
|
|
|
|
|
|
|
openai_api_key=api_key,
|
|
|
|
ai_name="Bumble Bee",
|
|
|
|
ai_name="Bumble Bee",
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
external_tools = None,
|
|
|
|
external_tools = None,
|
|
|
@ -104,20 +110,20 @@ for result in results:
|
|
|
|
- And, then place the openai api key in the Worker for the openai embedding model
|
|
|
|
- And, then place the openai api key in the Worker for the openai embedding model
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from swarms.models import ChatOpenAI
|
|
|
|
from swarms.models import OpenAIChat
|
|
|
|
from swarms.workers import Worker
|
|
|
|
from swarms import Worker
|
|
|
|
|
|
|
|
|
|
|
|
llm = ChatOpenAI(
|
|
|
|
api_key = ""
|
|
|
|
model_name='gpt-4',
|
|
|
|
|
|
|
|
openai_api_key="api-key",
|
|
|
|
llm = OpenAIChat(
|
|
|
|
temperature=0.5
|
|
|
|
openai_api_key=api_key,
|
|
|
|
|
|
|
|
temperature=0.5,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
node = Worker(
|
|
|
|
node = Worker(
|
|
|
|
llm=llm,
|
|
|
|
llm=llm,
|
|
|
|
ai_name="Optimus Prime",
|
|
|
|
ai_name="Optimus Prime",
|
|
|
|
#openai key for the embeddings
|
|
|
|
openai_api_key=api_key,
|
|
|
|
openai_api_key="sk-eee"
|
|
|
|
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
ai_role="Worker in a swarm",
|
|
|
|
external_tools=None,
|
|
|
|
external_tools=None,
|
|
|
|
human_in_the_loop=False,
|
|
|
|
human_in_the_loop=False,
|
|
|
@ -128,6 +134,7 @@ task = "What were the winning boston marathon times for the past 5 years (ending
|
|
|
|
response = node.run(task)
|
|
|
|
response = node.run(task)
|
|
|
|
print(response)
|
|
|
|
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
------
|
|
|
|
------
|
|
|
@ -139,8 +146,9 @@ print(response)
|
|
|
|
from swarms.models import OpenAIChat
|
|
|
|
from swarms.models import OpenAIChat
|
|
|
|
from swarms.agents import OmniModalAgent
|
|
|
|
from swarms.agents import OmniModalAgent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_key = "SK-"
|
|
|
|
|
|
|
|
|
|
|
|
llm = OpenAIChat(model_name="gpt-4")
|
|
|
|
llm = OpenAIChat(model_name="gpt-4", openai_api_key=api_key)
|
|
|
|
|
|
|
|
|
|
|
|
agent = OmniModalAgent(llm)
|
|
|
|
agent = OmniModalAgent(llm)
|
|
|
|
|
|
|
|
|
|
|
|