-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
667 additions
and
124 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,43 @@ | ||
# Swarms Tools Example with HTX + CoinGecko | ||
|
||
- `pip3 install swarms swarms-tools` | ||
- Add `OPENAI_API_KEY` to your `.env` file | ||
- Run `swarms_tools_htx_gecko.py` | ||
- Agent will make a function call to the desired tool | ||
- The tool will be executed and the result will be returned to the agent | ||
- The agent will then analyze the result and return the final output | ||
|
||
|
||
```python | ||
from swarms import Agent | ||
from swarms.prompts.finance_agent_sys_prompt import ( | ||
FINANCIAL_AGENT_SYS_PROMPT, | ||
) | ||
from swarms_tools import ( | ||
fetch_stock_news, | ||
coin_gecko_coin_api, | ||
fetch_htx_data, | ||
) | ||
|
||
# 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, | ||
model_name="gpt-4o", | ||
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 | ||
saved_state_path="agent_00.json", | ||
interactive=False, | ||
tools=[fetch_stock_news, coin_gecko_coin_api, fetch_htx_data], | ||
) | ||
|
||
agent.run("Analyze the $swarms token on htx") | ||
``` |
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "swarms" | ||
version = "6.8.8" | ||
version = "6.9.6" | ||
description = "Swarms - TGSC" | ||
license = "MIT" | ||
authors = ["Kye Gomez <[email protected]>"] | ||
|
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,33 @@ | ||
from swarms.utils.formatter import formatter | ||
|
||
|
||
def agent_print( | ||
agent_name: str, | ||
response: str = None, | ||
loop_count: int = None, | ||
streaming_on: bool = False, | ||
): | ||
""" | ||
Prints the response from an agent based on the streaming mode. | ||
Args: | ||
agent_name (str): The name of the agent. | ||
response (str): The response from the agent. | ||
loop_count (int): The maximum number of loops. | ||
streaming_on (bool): Indicates if streaming is on or off. | ||
Returns: | ||
str: The response from the agent. | ||
""" | ||
if streaming_on: | ||
formatter.print_panel_token_by_token( | ||
f"{agent_name}: {response}", | ||
title=f"Agent Name: {agent_name} [Max Loops: {loop_count}]", | ||
) | ||
else: | ||
formatter.print_panel( | ||
f"{agent_name}: {response}", | ||
f"Agent Name {agent_name} [Max Loops: {loop_count} ]", | ||
) | ||
|
||
return response |
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
Oops, something went wrong.