From 05e4201498d0b615fc72034384f345e5a386e24f Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Mon, 25 Aug 2025 19:51:18 -0700 Subject: [PATCH] [fix fluid api example] [fix scripts and organize it] --- docs/mkdocs.yml | 112 +++++++----------- docs/swarms_cloud/migration.md | 23 ++++ examples/demos/agent_with_fluidapi.py | 31 +---- .../{ => demos}/apps/smart_database_swarm.py | 0 scripts/{ => tests}/run_all_tests.py | 0 scripts/{ => tests}/test_rename_recursive.py | 0 .../test_upload_tests_to_issues.py | 0 swarms/utils/check_swarms_api_key.py | 19 +++ 8 files changed, 86 insertions(+), 99 deletions(-) create mode 100644 docs/swarms_cloud/migration.md rename examples/{ => demos}/apps/smart_database_swarm.py (100%) rename scripts/{ => tests}/run_all_tests.py (100%) rename scripts/{ => tests}/test_rename_recursive.py (100%) rename scripts/{ => tests}/test_upload_tests_to_issues.py (100%) create mode 100644 swarms/utils/check_swarms_api_key.py diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index fb3139cc..eb3dfc3f 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -375,18 +375,24 @@ nav: - Agent Output Types: "swarms/examples/agent_output_types.md" - Gradio Chat Interface: "swarms/ui/main.md" - LLM Providers: - - Overview: "swarms/examples/model_providers.md" - - OpenAI: "swarms/examples/openai_example.md" - - Anthropic: "swarms/examples/claude.md" - - Groq: "swarms/examples/groq.md" - - Cohere: "swarms/examples/cohere.md" - - DeepSeek: "swarms/examples/deepseek.md" - - Ollama: "swarms/examples/ollama.md" - - OpenRouter: "swarms/examples/openrouter.md" - - XAI: "swarms/examples/xai.md" - - Azure OpenAI: "swarms/examples/azure.md" - - VLLM: "swarms/examples/vllm_integration.md" - - Llama4: "swarms/examples/llama4.md" + - Language Models: + - How to Create A Custom Language Model: "swarms/models/custom_model.md" + - Overview: "swarms/examples/model_providers.md" + - OpenAI: "swarms/examples/openai_example.md" + - Anthropic: "swarms/examples/claude.md" + - Groq: "swarms/examples/groq.md" + - Cohere: "swarms/examples/cohere.md" + - DeepSeek: "swarms/examples/deepseek.md" + - Ollama: "swarms/examples/ollama.md" + - OpenRouter: "swarms/examples/openrouter.md" + - XAI: "swarms/examples/xai.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" - # - 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: - - Overview: "swarms_cloud/swarms_api.md" - - Quickstart: "swarms_cloud/quickstart.md" - - MCP Server: "swarms_cloud/mcp.md" - - Rate Limits: "swarms_cloud/rate_limits.md" - - Best Practices: "swarms_cloud/best_practices.md" - - - Capabilities: - - Agents: - - Individual Agent Completions: "swarms_cloud/agent_api.md" - - Tools: "swarms_cloud/swarms_api_tools.md" - - Multi-Agent: - - Multi Agent Architectures Available: "swarms_cloud/swarm_types.md" - - Swarm Types: - - AgentRearrange: "swarms_cloud/agent_rearrange.md" - - MixtureOfAgents: "swarms_cloud/mixture_of_agents.md" - - SequentialWorkflow: "swarms_cloud/sequential_workflow.md" - - ConcurrentWorkflow: "swarms_cloud/concurrent_workflow.md" - - GroupChat: "swarms_cloud/group_chat.md" - - MultiAgentRouter: "swarms_cloud/multi_agent_router.md" - - HierarchicalSwarm: "swarms_cloud/hierarchical_swarm.md" - - MajorityVoting: "swarms_cloud/majority_voting.md" - # - AutoSwarmBuilder: "swarms_cloud/auto_swarm_builder.md" - # - Auto: "swarms_cloud/auto.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" + - Overview: "swarms_cloud/migration.md" + + + # - Capabilities: + # - Agents: + # - Individual Agent Completions: "swarms_cloud/agent_api.md" + # - Tools: "swarms_cloud/swarms_api_tools.md" + # - Multi-Agent: + # - Multi Agent Architectures Available: "swarms_cloud/swarm_types.md" + # - Swarm Types: + # - AgentRearrange: "swarms_cloud/agent_rearrange.md" + # - MixtureOfAgents: "swarms_cloud/mixture_of_agents.md" + # - SequentialWorkflow: "swarms_cloud/sequential_workflow.md" + # - ConcurrentWorkflow: "swarms_cloud/concurrent_workflow.md" + # - GroupChat: "swarms_cloud/group_chat.md" + # - MultiAgentRouter: "swarms_cloud/multi_agent_router.md" + # - HierarchicalSwarm: "swarms_cloud/hierarchical_swarm.md" + # - MajorityVoting: "swarms_cloud/majority_voting.md" + # # - AutoSwarmBuilder: "swarms_cloud/auto_swarm_builder.md" + # # - Auto: "swarms_cloud/auto.md" + # - Examples: + # - Medical Swarm: "swarms/examples/swarms_api_medical.md" + # - Finance Swarm: "swarms/examples/swarms_api_finance.md" - Swarms Marketplace: - Overview: "swarms_platform/index.md" @@ -508,8 +483,3 @@ nav: - Architecture & Design: - Understanding Swarms Architecture: "swarms/concept/framework_architecture.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" diff --git a/docs/swarms_cloud/migration.md b/docs/swarms_cloud/migration.md new file mode 100644 index 00000000..df978499 --- /dev/null +++ b/docs/swarms_cloud/migration.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. You’ll find improved navigation, clearer guides, and up-to-date references for all Swarms Cloud API features. + +**What’s 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! \ No newline at end of file diff --git a/examples/demos/agent_with_fluidapi.py b/examples/demos/agent_with_fluidapi.py index cbaafc5a..72329e05 100644 --- a/examples/demos/agent_with_fluidapi.py +++ b/examples/demos/agent_with_fluidapi.py @@ -1,6 +1,3 @@ -import os - -from swarm_models import OpenAIChat from swarms import Agent from fluid_api_agent.main import fluid_api_request from dotenv import load_dotenv @@ -8,17 +5,6 @@ from dotenv import 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: """ @@ -98,22 +84,11 @@ agent = Agent( agent_name="API-Finance-Expert", agent_description="An API expert agent specialized in financial analysis and investment planning.", system_prompt=API_AGENT_SYS_PROMPT, - max_loops=1, # Allow a few iterations for refining outputs - llm=model, - 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 + model_name="gpt-4o-mini", + tools=[omni_api], ) # Run the agent with a financial task agent.run( - "Fetch the current price for eth", - all_cores=True, # Utilize all processing cores for efficiency + "Fetch the current price for eth with coingecko", ) diff --git a/examples/apps/smart_database_swarm.py b/examples/demos/apps/smart_database_swarm.py similarity index 100% rename from examples/apps/smart_database_swarm.py rename to examples/demos/apps/smart_database_swarm.py diff --git a/scripts/run_all_tests.py b/scripts/tests/run_all_tests.py similarity index 100% rename from scripts/run_all_tests.py rename to scripts/tests/run_all_tests.py diff --git a/scripts/test_rename_recursive.py b/scripts/tests/test_rename_recursive.py similarity index 100% rename from scripts/test_rename_recursive.py rename to scripts/tests/test_rename_recursive.py diff --git a/scripts/test_upload_tests_to_issues.py b/scripts/tests/test_upload_tests_to_issues.py similarity index 100% rename from scripts/test_upload_tests_to_issues.py rename to scripts/tests/test_upload_tests_to_issues.py diff --git a/swarms/utils/check_swarms_api_key.py b/swarms/utils/check_swarms_api_key.py new file mode 100644 index 00000000..2cf6797c --- /dev/null +++ b/swarms/utils/check_swarms_api_key.py @@ -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")