| Name | ai-mesh-sdk JSON |
| Version |
1.0.0
JSON |
| download |
| home_page | None |
| Summary | Professional Python SDK for Mesh AI Platform |
| upload_time | 2025-08-10 07:59:29 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.8 |
| license | None |
| keywords |
ai
mesh
sdk
api
llm
agents
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Mesh SDK
[](https://badge.fury.io/py/ai-mesh-sdk)
[](https://pypi.org/project/ai-mesh-sdk/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/your-org/mesh-sdk/actions/workflows/test.yml)
[](https://github.com/psf/black)
Professional Python SDK for the Mesh AI Platform. Easily integrate AI agents, tools, and LLMs into your Python applications with both synchronous and asynchronous support.
## Features
- ๐ **Easy to use**: Simple, intuitive API design
- โก **Async support**: Full async/await support for high-performance applications
- ๐ก๏ธ **Type safe**: Comprehensive type hints with Pydantic models
- ๐ **Retry logic**: Built-in exponential backoff for robust API calls
- ๐ **Comprehensive logging**: Detailed logging for debugging and monitoring
- ๐งช **Well tested**: Extensive test suite with >95% coverage
- ๐ **LangChain integration**: Optional integration with LangChain framework
- ๐ฏ **Multiple agent types**: Support for LLMs, autonomous agents, and tools
## Installation
### Basic Installation
```bash
pip install ai-mesh-sdk
```
### With Optional Dependencies
```bash
# With LangChain integration
pip install ai-mesh-sdk[langchain]
# For development
pip install ai-mesh-sdk[dev]
# All optional dependencies
pip install ai-mesh-sdk[langchain,dev]
```
## Quick Start
### Synchronous Client
```python
import os
from mesh_sdk import MeshClient
# Initialize the client
client = MeshClient(api_key=os.getenv("MESH_API_KEY"))
# List available agents
agents = client.list_agents()
print(f"Found {len(agents)} agents")
# Call an agent
response = client.call_agent(
agent_id="your-agent-id",
inputs={"query": "What is the weather today?"}
)
print(response.data)
# Chat completions (OpenAI-compatible)
messages = [{"role": "user", "content": "Hello!"}]
response = client.chat_completions(
model="gpt-3.5-turbo",
messages=messages,
temperature=0.7
)
print(response.choices[0].message.content)
```
### Asynchronous Client
```python
import asyncio
from mesh_sdk import AsyncMeshClient
async def main():
# Initialize async client
async with AsyncMeshClient(api_key=os.getenv("MESH_API_KEY")) as client:
# List agents asynchronously
agents = await client.list_agents()
print(f"Found {len(agents)} agents")
# Call agent asynchronously
response = await client.call_agent(
agent_id="your-agent-id",
inputs={"query": "Analyze this data"}
)
print(response.data)
# Async chat completions
messages = [{"role": "user", "content": "Hello!"}]
response = await client.chat_completions(
model="gpt-4",
messages=messages
)
print(response.choices[0].message.content)
# Run the async function
asyncio.run(main())
```
### Streaming Responses
```python
# Streaming chat completions
messages = [{"role": "user", "content": "Tell me a story"}]
for chunk in client.chat_completions(
model="gpt-3.5-turbo",
messages=messages,
stream=True
):
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
```
## Agent Types
The Mesh platform supports three types of agents:
### 1. LLMs (Large Language Models)
Direct access to language models via OpenAI-compatible chat completions:
```python
# List available LLMs
llms = client.list_llms()
# Use with chat completions
response = client.chat_completions(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)
```
### 2. Tools
Specialized functions that perform specific tasks:
```python
# List available tools
tools = client.list_tools()
# Call a tool
response = client.call_agent(
agent_id="search-tool-123",
inputs={"query": "Python programming", "max_results": 10}
)
```
### 3. Autonomous Agents
Complex workflows that can use multiple tools and make decisions:
```python
# List workflow agents
workflows = client.list_workflow_agents()
# Execute a workflow
response = client.call_agent(
agent_id="data-analysis-workflow-456",
inputs={"dataset_url": "https://example.com/data.csv"}
)
```
## LangChain Integration
Mesh SDK provides seamless integration with LangChain:
```python
from mesh_sdk import MeshClient
from mesh_sdk.integrations.langchain import to_langchain_tools
# Initialize client
client = MeshClient(api_key="your-api-key")
# Convert Mesh agents to LangChain tools
tools = to_langchain_tools(client)
# Use with LangChain agents
from langchain.agents import create_react_agent, AgentExecutor
from langchain import hub
# Get a prompt template
prompt = hub.pull("hwchase17/react")
# Create LangChain agent (you'll need a separate LLM)
agent = create_react_agent(your_llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Execute
response = agent_executor.invoke({
"input": "Search for information about climate change"
})
```
## Configuration
### Environment Variables
```bash
export MESH_API_KEY="your-api-key-here"
export MESH_BASE_URL="https://api.meshcore.ai" # Optional, defaults to official API
```
### Client Configuration
```python
from mesh_sdk import MeshClient
client = MeshClient(
api_key="your-api-key",
base_url="https://api.meshcore.ai", # Custom API endpoint
timeout=60.0, # Request timeout in seconds
max_retries=3, # Max retries for failed requests
retry_delay=1.0 # Base delay between retries
)
```
## Error Handling
The SDK provides specific exceptions for different error scenarios:
```python
from mesh_sdk import MeshClient
from mesh_sdk.exceptions import (
AuthenticationError,
AuthorizationError,
RateLimitError,
ValidationError,
APIError,
NetworkError,
TimeoutError
)
client = MeshClient(api_key="your-api-key")
try:
agents = client.list_agents()
except AuthenticationError:
print("Invalid API key")
except AuthorizationError:
print("Access denied")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except ValidationError as e:
print(f"Invalid input: {e}")
except NetworkError:
print("Network connection failed")
except TimeoutError:
print("Request timed out")
except APIError as e:
print(f"API error: {e}")
```
## Logging
The SDK uses Python's standard logging module:
```python
import logging
# Enable debug logging
logging.basicConfig(level=logging.DEBUG)
# Or configure specific logger
logger = logging.getLogger('mesh_sdk')
logger.setLevel(logging.INFO)
```
## Development
### Setup Development Environment
```bash
git clone https://github.com/your-org/mesh-sdk.git
cd mesh-sdk
pip install -e .[dev]
```
### Running Tests
```bash
# Run all tests
pytest
# Run with coverage
pytest --cov=mesh_sdk --cov-report=html
# Run specific test file
pytest tests/test_client.py
```
### Code Quality
```bash
# Format code
black src/ tests/
# Lint code
ruff src/ tests/
# Type checking
mypy src/
```
### Pre-commit Hooks
```bash
pip install pre-commit
pre-commit install
```
## Examples
See the [examples/](examples/) directory for complete example applications:
- [Basic Usage](examples/basic_usage.py) - Simple synchronous example
- [Async Usage](examples/async_usage.py) - Asynchronous client example
- [LangChain Integration](examples/langchain_integration.py) - Using with LangChain
- [Error Handling](examples/error_handling.py) - Comprehensive error handling
- [Streaming](examples/streaming.py) - Streaming responses
## API Reference
### MeshClient
The main synchronous client for the Mesh API.
#### Methods
- `list_agents()` โ `List[Agent]` - List all agents and tools (excluding LLMs)
- `list_tools()` โ `List[Agent]` - List only tools
- `list_workflow_agents()` โ `List[Agent]` - List only workflow agents
- `list_all_agents()` โ `List[Agent]` - List all agent types including LLMs
- `list_llms()` โ `List[Agent]` - List only LLMs
- `call_agent(agent_id, inputs, validate_inputs=True)` โ `AgentResponse` - Call an agent
- `chat_completions(model, messages, **kwargs)` โ `ChatCompletionResponse` - Create chat completion
### AsyncMeshClient
Asynchronous version of MeshClient with the same methods as async functions.
### Models
- `Agent` - Represents an agent, tool, or LLM
- `ChatMessage` - Individual chat message
- `ChatCompletionRequest` - Request for chat completions
- `ChatCompletionResponse` - Response from chat completions
- `AgentResponse` - Response from agent calls
## Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Add tests for new functionality
5. Ensure all tests pass (`pytest`)
6. Run code quality tools (`black`, `ruff`, `mypy`)
7. Commit your changes (`git commit -m 'Add amazing feature'`)
8. Push to the branch (`git push origin feature/amazing-feature`)
9. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- ๐ [Documentation](https://mesh-sdk.readthedocs.io)
- ๐ [Issue Tracker](https://github.com/your-org/mesh-sdk/issues)
- ๐ฌ [Discussions](https://github.com/your-org/mesh-sdk/discussions)
- ๐ง [Email Support](mailto:support@meshcore.ai)
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
---
Made with โค๏ธ by the Mesh AI Team
Raw data
{
"_id": null,
"home_page": null,
"name": "ai-mesh-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "ai, mesh, sdk, api, llm, agents",
"author": null,
"author_email": "Mesh AI Team <support@meshcore.ai>",
"download_url": "https://files.pythonhosted.org/packages/06/81/226fd78a1a5e51cebde8492e09885b745dd359af92eff53c29c56dcf4c83/ai_mesh_sdk-1.0.0.tar.gz",
"platform": null,
"description": "# Mesh SDK\n\n[](https://badge.fury.io/py/ai-mesh-sdk)\n[](https://pypi.org/project/ai-mesh-sdk/)\n[](https://opensource.org/licenses/MIT)\n[](https://github.com/your-org/mesh-sdk/actions/workflows/test.yml)\n[](https://github.com/psf/black)\n\nProfessional Python SDK for the Mesh AI Platform. Easily integrate AI agents, tools, and LLMs into your Python applications with both synchronous and asynchronous support.\n\n## Features\n\n- \ud83d\ude80 **Easy to use**: Simple, intuitive API design\n- \u26a1 **Async support**: Full async/await support for high-performance applications \n- \ud83d\udee1\ufe0f **Type safe**: Comprehensive type hints with Pydantic models\n- \ud83d\udd04 **Retry logic**: Built-in exponential backoff for robust API calls\n- \ud83d\udcdd **Comprehensive logging**: Detailed logging for debugging and monitoring\n- \ud83e\uddea **Well tested**: Extensive test suite with >95% coverage\n- \ud83d\udd0c **LangChain integration**: Optional integration with LangChain framework\n- \ud83c\udfaf **Multiple agent types**: Support for LLMs, autonomous agents, and tools\n\n## Installation\n\n### Basic Installation\n\n```bash\npip install ai-mesh-sdk\n```\n\n### With Optional Dependencies\n\n```bash\n# With LangChain integration\npip install ai-mesh-sdk[langchain]\n\n# For development\npip install ai-mesh-sdk[dev]\n\n# All optional dependencies\npip install ai-mesh-sdk[langchain,dev]\n```\n\n## Quick Start\n\n### Synchronous Client\n\n```python\nimport os\nfrom mesh_sdk import MeshClient\n\n# Initialize the client\nclient = MeshClient(api_key=os.getenv(\"MESH_API_KEY\"))\n\n# List available agents\nagents = client.list_agents()\nprint(f\"Found {len(agents)} agents\")\n\n# Call an agent\nresponse = client.call_agent(\n agent_id=\"your-agent-id\", \n inputs={\"query\": \"What is the weather today?\"}\n)\nprint(response.data)\n\n# Chat completions (OpenAI-compatible)\nmessages = [{\"role\": \"user\", \"content\": \"Hello!\"}]\nresponse = client.chat_completions(\n model=\"gpt-3.5-turbo\",\n messages=messages,\n temperature=0.7\n)\nprint(response.choices[0].message.content)\n```\n\n### Asynchronous Client\n\n```python\nimport asyncio\nfrom mesh_sdk import AsyncMeshClient\n\nasync def main():\n # Initialize async client\n async with AsyncMeshClient(api_key=os.getenv(\"MESH_API_KEY\")) as client:\n \n # List agents asynchronously\n agents = await client.list_agents()\n print(f\"Found {len(agents)} agents\")\n \n # Call agent asynchronously \n response = await client.call_agent(\n agent_id=\"your-agent-id\",\n inputs={\"query\": \"Analyze this data\"}\n )\n print(response.data)\n \n # Async chat completions\n messages = [{\"role\": \"user\", \"content\": \"Hello!\"}]\n response = await client.chat_completions(\n model=\"gpt-4\",\n messages=messages\n )\n print(response.choices[0].message.content)\n\n# Run the async function\nasyncio.run(main())\n```\n\n### Streaming Responses\n\n```python\n# Streaming chat completions\nmessages = [{\"role\": \"user\", \"content\": \"Tell me a story\"}]\n\nfor chunk in client.chat_completions(\n model=\"gpt-3.5-turbo\",\n messages=messages,\n stream=True\n):\n if chunk.choices[0].delta.content:\n print(chunk.choices[0].delta.content, end=\"\")\n```\n\n## Agent Types\n\nThe Mesh platform supports three types of agents:\n\n### 1. LLMs (Large Language Models)\nDirect access to language models via OpenAI-compatible chat completions:\n\n```python\n# List available LLMs\nllms = client.list_llms()\n\n# Use with chat completions\nresponse = client.chat_completions(\n model=\"gpt-4\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\n```\n\n### 2. Tools\nSpecialized functions that perform specific tasks:\n\n```python\n# List available tools\ntools = client.list_tools()\n\n# Call a tool\nresponse = client.call_agent(\n agent_id=\"search-tool-123\",\n inputs={\"query\": \"Python programming\", \"max_results\": 10}\n)\n```\n\n### 3. Autonomous Agents\nComplex workflows that can use multiple tools and make decisions:\n\n```python\n# List workflow agents\nworkflows = client.list_workflow_agents()\n\n# Execute a workflow\nresponse = client.call_agent(\n agent_id=\"data-analysis-workflow-456\", \n inputs={\"dataset_url\": \"https://example.com/data.csv\"}\n)\n```\n\n## LangChain Integration\n\nMesh SDK provides seamless integration with LangChain:\n\n```python\nfrom mesh_sdk import MeshClient\nfrom mesh_sdk.integrations.langchain import to_langchain_tools\n\n# Initialize client\nclient = MeshClient(api_key=\"your-api-key\")\n\n# Convert Mesh agents to LangChain tools\ntools = to_langchain_tools(client)\n\n# Use with LangChain agents\nfrom langchain.agents import create_react_agent, AgentExecutor\nfrom langchain import hub\n\n# Get a prompt template\nprompt = hub.pull(\"hwchase17/react\")\n\n# Create LangChain agent (you'll need a separate LLM)\nagent = create_react_agent(your_llm, tools, prompt)\nagent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)\n\n# Execute\nresponse = agent_executor.invoke({\n \"input\": \"Search for information about climate change\"\n})\n```\n\n## Configuration\n\n### Environment Variables\n\n```bash\nexport MESH_API_KEY=\"your-api-key-here\"\nexport MESH_BASE_URL=\"https://api.meshcore.ai\" # Optional, defaults to official API\n```\n\n### Client Configuration\n\n```python\nfrom mesh_sdk import MeshClient\n\nclient = MeshClient(\n api_key=\"your-api-key\",\n base_url=\"https://api.meshcore.ai\", # Custom API endpoint\n timeout=60.0, # Request timeout in seconds\n max_retries=3, # Max retries for failed requests\n retry_delay=1.0 # Base delay between retries\n)\n```\n\n## Error Handling\n\nThe SDK provides specific exceptions for different error scenarios:\n\n```python\nfrom mesh_sdk import MeshClient\nfrom mesh_sdk.exceptions import (\n AuthenticationError,\n AuthorizationError, \n RateLimitError,\n ValidationError,\n APIError,\n NetworkError,\n TimeoutError\n)\n\nclient = MeshClient(api_key=\"your-api-key\")\n\ntry:\n agents = client.list_agents()\nexcept AuthenticationError:\n print(\"Invalid API key\")\nexcept AuthorizationError:\n print(\"Access denied\")\nexcept RateLimitError as e:\n print(f\"Rate limited. Retry after {e.retry_after} seconds\")\nexcept ValidationError as e:\n print(f\"Invalid input: {e}\")\nexcept NetworkError:\n print(\"Network connection failed\")\nexcept TimeoutError:\n print(\"Request timed out\")\nexcept APIError as e:\n print(f\"API error: {e}\")\n```\n\n## Logging\n\nThe SDK uses Python's standard logging module:\n\n```python\nimport logging\n\n# Enable debug logging\nlogging.basicConfig(level=logging.DEBUG)\n\n# Or configure specific logger\nlogger = logging.getLogger('mesh_sdk')\nlogger.setLevel(logging.INFO)\n```\n\n## Development\n\n### Setup Development Environment\n\n```bash\ngit clone https://github.com/your-org/mesh-sdk.git\ncd mesh-sdk\npip install -e .[dev]\n```\n\n### Running Tests\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=mesh_sdk --cov-report=html\n\n# Run specific test file\npytest tests/test_client.py\n```\n\n### Code Quality\n\n```bash\n# Format code\nblack src/ tests/\n\n# Lint code \nruff src/ tests/\n\n# Type checking\nmypy src/\n```\n\n### Pre-commit Hooks\n\n```bash\npip install pre-commit\npre-commit install\n```\n\n## Examples\n\nSee the [examples/](examples/) directory for complete example applications:\n\n- [Basic Usage](examples/basic_usage.py) - Simple synchronous example\n- [Async Usage](examples/async_usage.py) - Asynchronous client example \n- [LangChain Integration](examples/langchain_integration.py) - Using with LangChain\n- [Error Handling](examples/error_handling.py) - Comprehensive error handling\n- [Streaming](examples/streaming.py) - Streaming responses\n\n## API Reference\n\n### MeshClient\n\nThe main synchronous client for the Mesh API.\n\n#### Methods\n\n- `list_agents()` \u2192 `List[Agent]` - List all agents and tools (excluding LLMs)\n- `list_tools()` \u2192 `List[Agent]` - List only tools\n- `list_workflow_agents()` \u2192 `List[Agent]` - List only workflow agents\n- `list_all_agents()` \u2192 `List[Agent]` - List all agent types including LLMs\n- `list_llms()` \u2192 `List[Agent]` - List only LLMs\n- `call_agent(agent_id, inputs, validate_inputs=True)` \u2192 `AgentResponse` - Call an agent\n- `chat_completions(model, messages, **kwargs)` \u2192 `ChatCompletionResponse` - Create chat completion\n\n### AsyncMeshClient\n\nAsynchronous version of MeshClient with the same methods as async functions.\n\n### Models\n\n- `Agent` - Represents an agent, tool, or LLM\n- `ChatMessage` - Individual chat message\n- `ChatCompletionRequest` - Request for chat completions\n- `ChatCompletionResponse` - Response from chat completions\n- `AgentResponse` - Response from agent calls\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Add tests for new functionality\n5. Ensure all tests pass (`pytest`)\n6. Run code quality tools (`black`, `ruff`, `mypy`)\n7. Commit your changes (`git commit -m 'Add amazing feature'`)\n8. Push to the branch (`git push origin feature/amazing-feature`)\n9. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- \ud83d\udcd6 [Documentation](https://mesh-sdk.readthedocs.io)\n- \ud83d\udc1b [Issue Tracker](https://github.com/your-org/mesh-sdk/issues) \n- \ud83d\udcac [Discussions](https://github.com/your-org/mesh-sdk/discussions)\n- \ud83d\udce7 [Email Support](mailto:support@meshcore.ai)\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.\n\n---\n\nMade with \u2764\ufe0f by the Mesh AI Team\n",
"bugtrack_url": null,
"license": null,
"summary": "Professional Python SDK for Mesh AI Platform",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/your-org/ai-mesh-sdk",
"Repository": "https://github.com/your-org/ai-mesh-sdk.git"
},
"split_keywords": [
"ai",
" mesh",
" sdk",
" api",
" llm",
" agents"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "311f64ad93a5ddc7a8115c2bbfd46acbaeac8acf836760ef9a26bc07de933e5e",
"md5": "2badf1eb7a417f9000501d69117f5400",
"sha256": "e055f2381f3f15a396fdb07dc599d619a06981807ff4fc78cc6bb214bc0a5d15"
},
"downloads": -1,
"filename": "ai_mesh_sdk-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2badf1eb7a417f9000501d69117f5400",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 16360,
"upload_time": "2025-08-10T07:59:28",
"upload_time_iso_8601": "2025-08-10T07:59:28.617341Z",
"url": "https://files.pythonhosted.org/packages/31/1f/64ad93a5ddc7a8115c2bbfd46acbaeac8acf836760ef9a26bc07de933e5e/ai_mesh_sdk-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0681226fd78a1a5e51cebde8492e09885b745dd359af92eff53c29c56dcf4c83",
"md5": "94def88626e3d5b56e4819db826a4555",
"sha256": "b6643ba611b0cdb3e09d9d0b87f2ab72e3d7748b90282bb92c5a1fb6b18b26c7"
},
"downloads": -1,
"filename": "ai_mesh_sdk-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "94def88626e3d5b56e4819db826a4555",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 22336,
"upload_time": "2025-08-10T07:59:29",
"upload_time_iso_8601": "2025-08-10T07:59:29.963403Z",
"url": "https://files.pythonhosted.org/packages/06/81/226fd78a1a5e51cebde8492e09885b745dd359af92eff53c29c56dcf4c83/ai_mesh_sdk-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-10 07:59:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "your-org",
"github_project": "ai-mesh-sdk",
"github_not_found": true,
"lcname": "ai-mesh-sdk"
}