[fix fluid api example] [fix scripts and organize it]

pull/1046/head
Kye Gomez 1 week ago
parent da3421447a
commit 05e4201498

@ -375,18 +375,24 @@ nav:
- Agent Output Types: "swarms/examples/agent_output_types.md" - Agent Output Types: "swarms/examples/agent_output_types.md"
- Gradio Chat Interface: "swarms/ui/main.md" - Gradio Chat Interface: "swarms/ui/main.md"
- LLM Providers: - LLM Providers:
- Overview: "swarms/examples/model_providers.md" - Language Models:
- OpenAI: "swarms/examples/openai_example.md" - How to Create A Custom Language Model: "swarms/models/custom_model.md"
- Anthropic: "swarms/examples/claude.md" - Overview: "swarms/examples/model_providers.md"
- Groq: "swarms/examples/groq.md" - OpenAI: "swarms/examples/openai_example.md"
- Cohere: "swarms/examples/cohere.md" - Anthropic: "swarms/examples/claude.md"
- DeepSeek: "swarms/examples/deepseek.md" - Groq: "swarms/examples/groq.md"
- Ollama: "swarms/examples/ollama.md" - Cohere: "swarms/examples/cohere.md"
- OpenRouter: "swarms/examples/openrouter.md" - DeepSeek: "swarms/examples/deepseek.md"
- XAI: "swarms/examples/xai.md" - Ollama: "swarms/examples/ollama.md"
- Azure OpenAI: "swarms/examples/azure.md" - OpenRouter: "swarms/examples/openrouter.md"
- VLLM: "swarms/examples/vllm_integration.md" - XAI: "swarms/examples/xai.md"
- Llama4: "swarms/examples/llama4.md" - Azure OpenAI: "swarms/examples/azure.md"
- VLLM: "swarms/examples/vllm_integration.md"
- Llama4: "swarms/examples/llama4.md"
- MultiModal Models:
- BaseMultiModalModel: "swarms/models/base_multimodal_model.md"
- Multi Modal Models Available: "swarms/models/multimodal_models.md"
- GPT4VisionAPI: "swarms/models/gpt4v.md"
@ -423,61 +429,30 @@ nav:
- Smart Database: "examples/smart_database.md" - Smart Database: "examples/smart_database.md"
# - Swarm Models:
# - Overview: "swarms/models/index.md"
# # - Models Available: "swarms/models/index.md"
# # - Available Models from OpenAI, Huggingface, TogetherAI, and more: "swarms/models/models_available_overview.md"
# # - Model Router
# - Quickstart: "swarms/models/models_available_overview.md"
# - How to Create A Custom Language Model: "swarms/models/custom_model.md"
# - Language Models:
# - BaseLLM: "swarms/models/base_llm.md"
# - HuggingFaceLLM: "swarms/models/huggingface.md"
# - Anthropic: "swarms/models/anthropic.md"
# - OpenAIChat: "swarms/models/openai.md"
# - OpenAIFunctionCaller: "swarms/models/openai_function_caller.md"
# - Groq: "swarms/models/groq.md"
# - Cerebras: "swarms/models/cerebras.md"
# - MultiModal Models:
# - BaseMultiModalModel: "swarms/models/base_multimodal_model.md"
# - Multi Modal Models Available: "swarms/models/multimodal_models.md"
# - GPT4VisionAPI: "swarms/models/gpt4v.md"
- Swarms Cloud API: - Swarms Cloud API:
- Overview: "swarms_cloud/swarms_api.md" - Overview: "swarms_cloud/migration.md"
- Quickstart: "swarms_cloud/quickstart.md"
- MCP Server: "swarms_cloud/mcp.md"
- Rate Limits: "swarms_cloud/rate_limits.md" # - Capabilities:
- Best Practices: "swarms_cloud/best_practices.md" # - Agents:
# - Individual Agent Completions: "swarms_cloud/agent_api.md"
- Capabilities: # - Tools: "swarms_cloud/swarms_api_tools.md"
- Agents: # - Multi-Agent:
- Individual Agent Completions: "swarms_cloud/agent_api.md" # - Multi Agent Architectures Available: "swarms_cloud/swarm_types.md"
- Tools: "swarms_cloud/swarms_api_tools.md" # - Swarm Types:
- Multi-Agent: # - AgentRearrange: "swarms_cloud/agent_rearrange.md"
- Multi Agent Architectures Available: "swarms_cloud/swarm_types.md" # - MixtureOfAgents: "swarms_cloud/mixture_of_agents.md"
- Swarm Types: # - SequentialWorkflow: "swarms_cloud/sequential_workflow.md"
- AgentRearrange: "swarms_cloud/agent_rearrange.md" # - ConcurrentWorkflow: "swarms_cloud/concurrent_workflow.md"
- MixtureOfAgents: "swarms_cloud/mixture_of_agents.md" # - GroupChat: "swarms_cloud/group_chat.md"
- SequentialWorkflow: "swarms_cloud/sequential_workflow.md" # - MultiAgentRouter: "swarms_cloud/multi_agent_router.md"
- ConcurrentWorkflow: "swarms_cloud/concurrent_workflow.md" # - HierarchicalSwarm: "swarms_cloud/hierarchical_swarm.md"
- GroupChat: "swarms_cloud/group_chat.md" # - MajorityVoting: "swarms_cloud/majority_voting.md"
- MultiAgentRouter: "swarms_cloud/multi_agent_router.md" # # - AutoSwarmBuilder: "swarms_cloud/auto_swarm_builder.md"
- HierarchicalSwarm: "swarms_cloud/hierarchical_swarm.md" # # - Auto: "swarms_cloud/auto.md"
- MajorityVoting: "swarms_cloud/majority_voting.md" # - Examples:
# - AutoSwarmBuilder: "swarms_cloud/auto_swarm_builder.md" # - Medical Swarm: "swarms/examples/swarms_api_medical.md"
# - Auto: "swarms_cloud/auto.md" # - Finance Swarm: "swarms/examples/swarms_api_finance.md"
- Examples:
- Medical Swarm: "swarms/examples/swarms_api_medical.md"
- Finance Swarm: "swarms/examples/swarms_api_finance.md"
- Clients:
- Overview: "swarms_cloud/api_clients.md"
- Python Client: "swarms_cloud/python_client.md"
- Rust Client: "swarms_cloud/rust_client.md"
- Pricing:
- Pricing: "swarms_cloud/api_pricing.md"
- Subscription Tiers: "swarms_cloud/subscription_tiers.md"
- Swarms Marketplace: - Swarms Marketplace:
- Overview: "swarms_platform/index.md" - Overview: "swarms_platform/index.md"
@ -508,8 +483,3 @@ nav:
- Architecture & Design: - Architecture & Design:
- Understanding Swarms Architecture: "swarms/concept/framework_architecture.md" - Understanding Swarms Architecture: "swarms/concept/framework_architecture.md"
- Development Philosophy & Principles: "swarms/concept/philosophy.md" - Development Philosophy & Principles: "swarms/concept/philosophy.md"
# - About Swarms:
# - Vision & Mission: "swarms/concept/vision.md"
# - Swarm Ecosystem: "swarms/concept/swarm_ecosystem.md"
# - Products: "swarms/products.md"

@ -0,0 +1,23 @@
# Swarms API Documentation Has Moved 🚀
We are excited to announce that the documentation for the Swarms API has been migrated to a brand new platform: [docs.swarms.ai](https://docs.swarms.ai).
Our new documentation site offers a more beautiful, user-friendly, and streamlined experience for developers and users alike. Youll find improved navigation, clearer guides, and up-to-date references for all Swarms Cloud API features.
**Whats new at [docs.swarms.ai](https://docs.swarms.ai)?**
- Modern, easy-to-navigate interface
- Comprehensive API reference and usage examples
- Quickstart guides and best practices
- Regular updates and new content
- Enhanced search and accessibility
If you have previously bookmarked or referenced the old documentation, please update your links to point to the new site. All future updates, new features, and support resources will be available exclusively at [docs.swarms.ai](https://docs.swarms.ai).
Thank you for being part of the Swarms community! If you have any questions or feedback about the new documentation, feel free to reach out via our [Discord](https://discord.gg/EamjgSaEQf) or [GitHub](https://github.com/kyegomez/swarms).
Happy building with Swarms!

@ -1,6 +1,3 @@
import os
from swarm_models import OpenAIChat
from swarms import Agent from swarms import Agent
from fluid_api_agent.main import fluid_api_request from fluid_api_agent.main import fluid_api_request
from dotenv import load_dotenv from dotenv import load_dotenv
@ -8,17 +5,6 @@ from dotenv import load_dotenv
load_dotenv() load_dotenv()
# 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,
)
def omni_api(task: str) -> str: def omni_api(task: str) -> str:
""" """
@ -98,22 +84,11 @@ agent = Agent(
agent_name="API-Finance-Expert", agent_name="API-Finance-Expert",
agent_description="An API expert agent specialized in financial analysis and investment planning.", agent_description="An API expert agent specialized in financial analysis and investment planning.",
system_prompt=API_AGENT_SYS_PROMPT, system_prompt=API_AGENT_SYS_PROMPT,
max_loops=1, # Allow a few iterations for refining outputs model_name="gpt-4o-mini",
llm=model, tools=[omni_api],
dynamic_temperature_enabled=True, # Enable temperature adjustments for optimal creativity
user_name="swarms_corp",
retry_attempts=5, # Retry API calls to ensure reliability
context_length=8192, # Context length for comprehensive analysis
return_step_meta=False,
output_type="str", # Output tables or results in markdown format
auto_generate_prompt=False, # Use the custom system prompt for guidance
max_tokens=4000,
saved_state_path="api_finance_expert.json",
tools=[omni_api], # Integrate the omni_api tool
) )
# Run the agent with a financial task # Run the agent with a financial task
agent.run( agent.run(
"Fetch the current price for eth", "Fetch the current price for eth with coingecko",
all_cores=True, # Utilize all processing cores for efficiency
) )

@ -0,0 +1,19 @@
import os
def check_swarms_api_key():
"""
Check if the Swarms API key is set.
Returns:
str: The value of the SWARMS_API_KEY environment variable.
Raises:
ValueError: If the SWARMS_API_KEY environment variable is not set.
"""
if os.getenv("SWARMS_API_KEY") is None:
raise ValueError(
"Swarms API key is not set. Please set the SWARMS_API_KEY environment variable. "
"You can get your key here: https://swarms.world/platform/api-keys"
)
return os.getenv("SWARMS_API_KEY")
Loading…
Cancel
Save