-
-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
# Conflicts: # docs/zh/swarms/examples/claude.md # docs/zh/swarms/examples/cohere.md # docs/zh/swarms/examples/deepseek.md # docs/zh/swarms/examples/groq.md # docs/zh/swarms/examples/ollama.md # docs/zh/swarms/examples/openai_example.md # docs/zh/swarms/examples/openrouter.md # docs/zh/swarms/examples/xai.md
- Loading branch information
Showing
23 changed files
with
320 additions
and
656 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
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,70 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
from openai import OpenAI | ||
|
||
from swarms import Agent | ||
from swarms.prompts.finance_agent_sys_prompt import ( | ||
FINANCIAL_AGENT_SYS_PROMPT, | ||
) | ||
|
||
load_dotenv() | ||
|
||
|
||
class DeepSeekChat: | ||
def __init__( | ||
self, | ||
api_key: str = os.getenv("DEEPSEEK_API_KEY"), | ||
system_prompt: str = None, | ||
): | ||
self.api_key = api_key | ||
|
||
self.client = OpenAI( | ||
api_key=api_key, base_url="https://api.deepseek.com" | ||
) | ||
|
||
def run(self, task: str): | ||
response = self.client.chat.completions.create( | ||
model="deepseek-chat", | ||
messages=[ | ||
{ | ||
"role": "system", | ||
"content": "You are a helpful assistant", | ||
}, | ||
{"role": "user", "content": task}, | ||
], | ||
stream=False, | ||
) | ||
|
||
print(response) | ||
|
||
out = response.choices[0].message.content | ||
print(out) | ||
|
||
return out | ||
|
||
|
||
model = DeepSeekChat() | ||
|
||
# Initialize the agent | ||
agent = Agent( | ||
agent_name="Financial-Analysis-Agent", | ||
agent_description="Personal finance advisor agent", | ||
system_prompt=FINANCIAL_AGENT_SYS_PROMPT, | ||
max_loops=1, | ||
llm=model, | ||
dynamic_temperature_enabled=True, | ||
user_name="swarms_corp", | ||
retry_attempts=3, | ||
context_length=8192, | ||
return_step_meta=False, | ||
output_type="str", # "json", "dict", "csv" OR "string" "yaml" and | ||
auto_generate_prompt=False, # Auto generate prompt for the agent based on name, description, and system prompt, task | ||
max_tokens=4000, # max output tokens | ||
) | ||
|
||
print( | ||
agent.run( | ||
"Create a table of super high growth opportunities for AI. I have $40k to invest in ETFs, index funds, and more. Please create a table in markdown.", | ||
) | ||
) |
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
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,25 @@ | ||
# Agent with Anthropic/Claude | ||
|
||
- Get their api keys and put it in the `.env` | ||
|
||
- Select your model_name like `claude-3-sonnet-20240229` follows LiteLLM conventions | ||
|
||
|
||
```python | ||
from swarms import Agent | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Initialize the agent with ChromaDB memory | ||
agent = Agent( | ||
agent_name="Financial-Analysis-Agent", | ||
model_name="claude-3-sonnet-20240229", | ||
system_prompt="Agent system prompt here", | ||
agent_description="Agent performs financial analysis.", | ||
) | ||
|
||
# Run a query | ||
agent.run("What are the components of a startup's stock incentive equity plan?") | ||
``` |
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,25 @@ | ||
# Agent with Cohere | ||
|
||
- Add your `COHERE_API_KEY` in the `.env` file | ||
|
||
- Select your model_name like `command-r` follows LiteLLM conventions | ||
|
||
|
||
```python | ||
from swarms import Agent | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Initialize the agent with ChromaDB memory | ||
agent = Agent( | ||
agent_name="Financial-Analysis-Agent", | ||
model_name="command-r", | ||
system_prompt="Agent system prompt here", | ||
agent_description="Agent performs financial analysis.", | ||
) | ||
|
||
# Run a query | ||
agent.run("What are the components of a startup's stock incentive equity plan?") | ||
``` |
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,27 @@ | ||
# Agent with DeepSeek | ||
|
||
- Add your `DEEPSEEK_API_KEY` in the `.env` file | ||
|
||
- Select your model_name like `deepseek/deepseek-chat` follows [LiteLLM conventions](https://docs.litellm.ai/docs/providers/deepseek) | ||
|
||
- Execute your agent! | ||
|
||
|
||
```python | ||
from swarms import Agent | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Initialize the agent with ChromaDB memory | ||
agent = Agent( | ||
agent_name="Financial-Analysis-Agent", | ||
model_name="deepseek/deepseek-chat", | ||
system_prompt="Agent system prompt here", | ||
agent_description="Agent performs financial analysis.", | ||
) | ||
|
||
# Run a query | ||
agent.run("What are the components of a startup's stock incentive equity plan?") | ||
``` |
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 @@ | ||
# Agent with Groq | ||
|
||
- Add your `GROQ_API_KEY` | ||
|
||
```python | ||
import os | ||
|
||
from swarm_models import OpenAIChat | ||
|
||
from swarms import Agent | ||
|
||
company = "NVDA" | ||
|
||
# Get the OpenAI API key from the environment variable | ||
api_key = os.getenv("GROQ_API_KEY") | ||
|
||
# Model | ||
model = OpenAIChat( | ||
openai_api_base="https://api.groq.com/openai/v1", | ||
openai_api_key=api_key, | ||
model_name="llama-3.1-70b-versatile", | ||
temperature=0.1, | ||
) | ||
|
||
|
||
# Initialize the Managing Director agent | ||
managing_director = Agent( | ||
agent_name="Managing-Director", | ||
system_prompt=f""" | ||
As the Managing Director at Blackstone, your role is to oversee the entire investment analysis process for potential acquisitions. | ||
Your responsibilities include: | ||
1. Setting the overall strategy and direction for the analysis | ||
2. Coordinating the efforts of the various team members and ensuring a comprehensive evaluation | ||
3. Reviewing the findings and recommendations from each team member | ||
4. Making the final decision on whether to proceed with the acquisition | ||
For the current potential acquisition of {company}, direct the tasks for the team to thoroughly analyze all aspects of the company, including its financials, industry position, technology, market potential, and regulatory compliance. Provide guidance and feedback as needed to ensure a rigorous and unbiased assessment. | ||
""", | ||
llm=model, | ||
max_loops=1, | ||
dashboard=False, | ||
streaming_on=True, | ||
verbose=True, | ||
stopping_token="<DONE>", | ||
state_save_file_type="json", | ||
saved_state_path="managing-director.json", | ||
) | ||
``` |
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,24 @@ | ||
# Agent with Ollama | ||
|
||
- No API key needed | ||
- Select your model_name like `ollama/llama2` follows [LiteLLM conventions](https://docs.litellm.ai/docs/providers/ollama) | ||
|
||
|
||
```python | ||
from swarms import Agent | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Initialize the agent with ChromaDB memory | ||
agent = Agent( | ||
agent_name="Financial-Analysis-Agent", | ||
model_name="ollama/llama2", | ||
system_prompt="Agent system prompt here", | ||
agent_description="Agent performs financial analysis.", | ||
) | ||
|
||
# Run a query | ||
agent.run("What are the components of a startup's stock incentive equity plan?") | ||
``` |
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,16 @@ | ||
# Agent with GPT-4o-Mini | ||
|
||
- Add `OPENAI_API_KEY="your_key"` to your `.env` file | ||
- Select your model like `gpt-4o-mini` or `gpt-4o` | ||
|
||
```python | ||
from swarms import Agent | ||
|
||
Agent( | ||
agent_name="Stock-Analysis-Agent", | ||
model_name="gpt-4o-mini", | ||
max_loops="auto", | ||
interactive=True, | ||
streaming_on=True, | ||
).run("What are 5 hft algorithms") | ||
``` |
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,27 @@ | ||
# Agent with OpenRouter | ||
|
||
- Add your `OPENROUTER_API_KEY` in the `.env` file | ||
|
||
- Select your model_name like `openrouter/google/palm-2-chat-bison` follows [LiteLLM conventions](https://docs.litellm.ai/docs/providers/openrouter) | ||
|
||
- Execute your agent! | ||
|
||
|
||
```python | ||
from swarms import Agent | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Initialize the agent with ChromaDB memory | ||
agent = Agent( | ||
agent_name="Financial-Analysis-Agent", | ||
model_name="openrouter/google/palm-2-chat-bison", | ||
system_prompt="Agent system prompt here", | ||
agent_description="Agent performs financial analysis.", | ||
) | ||
|
||
# Run a query | ||
agent.run("What are the components of a startup's stock incentive equity plan?") | ||
``` |
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,27 @@ | ||
# Agent with XAI | ||
|
||
- Add your `XAI_API_KEY` in the `.env` file | ||
|
||
- Select your model_name like `xai/grok-beta` follows [LiteLLM conventions](https://docs.litellm.ai/docs/providers/xai) | ||
|
||
- Execute your agent! | ||
|
||
|
||
```python | ||
from swarms import Agent | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
# Initialize the agent with ChromaDB memory | ||
agent = Agent( | ||
agent_name="Financial-Analysis-Agent", | ||
model_name="xai/grok-beta", | ||
system_prompt="Agent system prompt here", | ||
agent_description="Agent performs financial analysis.", | ||
) | ||
|
||
# Run a query | ||
agent.run("What are the components of a startup's stock incentive equity plan?") | ||
``` |
5 changes: 4 additions & 1 deletion
5
csvagent_example.py → new_features_examples/csvagent_example.py
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.