Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Swarms API Middleware Example This repository contains a Python script that interacts with the Swarms API to perform user creation, API key creation, and agent creation. The script also attempts to generate completions using the created agent. Below is a detailed explanation of what was accomplished and the issues encountered.

Accomplishments 1. User Creation The script successfully creates a new user by sending a POST request to the /v1/users endpoint. The user creation process returns an API key and a user ID, which are stored for subsequent API calls.

2. API Key Creation After creating a user, the script generates a new API key for the user by sending a POST request to the /v1/users/{user_id}/api-keys endpoint. This API key is used for authenticating subsequent API calls.

3. Agent Creation The script creates an agent by sending a POST request to the /v1/agent endpoint. The agent is configured with various parameters such as the agent name, model name, system prompt, temperature, and other settings. The agent creation process returns an agent ID, which is used for generating completions.

Issues Encountered Generate Completion During the generate completion step, the script sends a POST request to the /v1/agent/completions endpoint with the agent ID and the prompt. However, the API consistently returns "None" as the response. This issue prevents the script from generating meaningful completions.

Debugging and Analysis The script includes detailed debugging information to help identify the cause of the issue. The following steps were taken to diagnose the problem:

API Key Validation: Ensured that the API key used for the completion request is valid and has the necessary permissions.

Agent Readiness: Verified that the agent is correctly set up and ready to process completion requests. Prompt Formatting: Ensured that the prompt is correctly formatted and provides enough context for the model to generate a meaningful response.

Necessary Backend API Changes To resolve the issue with the API returning "None" during the generate completion step, the following changes to the backend API are necessary:

-Completion Response Handling: The backend API should handle the completion response correctly and ensure that it returns a meaningful response instead of "None". -Error Messaging: The backend API should provide more detailed error messages to help diagnose issues with completion generation. -Agent Status Verification: The backend API should verify the status of the agent and ensure that it is ready to process completion requests before returning a response.

Conclusion The script successfully demonstrates user creation, API key creation, and agent creation using the Swarms API. However, the issue with the API returning "None" during the generate completion step highlights the need for changes to the backend API. Once these changes are implemented, the script will be able to generate meaningful completions using the created agent.

Future Work

-Implement Backend API Changes: Work with the backend team to implement the necessary changes to the API. -Test Completion Generation: After the backend API changes are implemented, test the completion generation process to ensure that it returns meaningful responses. -Enhance Error Handling: Improve the error handling in the script to provide more detailed information about any issues encountered during the API interaction.

About

Get started with the Swarms api for AI agents in your web applications

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages