| Name | metorial-deepseek JSON |
| Version |
1.0.4
JSON |
| download |
| home_page | None |
| Summary | DeepSeek provider for Metorial |
| upload_time | 2025-10-30 05:03:17 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.10 |
| license | MIT |
| keywords |
ai
deepseek
llm
metorial
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# metorial-deepseek
DeepSeek provider integration for Metorial.
## Installation
```bash
pip install metorial-deepseek
# or
uv add metorial-deepseek
# or
poetry add metorial-deepseek
```
## Features
- š¤ **DeepSeek Integration**: Full support for DeepSeek Chat, DeepSeek Coder, and other models
- š” **Session Management**: Automatic tool lifecycle handling
- š **Format Conversion**: Converts Metorial tools to OpenAI function format
- ā” **Async Support**: Full async/await support
## Supported Models
All DeepSeek models available through their API:
- `deepseek-chat`: General-purpose conversational model
- `deepseek-coder`: Specialized for code-related tasks
## Usage
### Quick Start (Recommended)
```python
import asyncio
from openai import AsyncOpenAI
from metorial import Metorial
async def main():
# Initialize clients
metorial = Metorial(api_key="...your-metorial-api-key...") # async by default
deepseek_client = AsyncOpenAI(
api_key="...your-deepseek-api-key...",
base_url="https://api.deepseek.com"
)
# One-liner chat with automatic session management
response = await metorial.run(
"What are the latest commits in the metorial/websocket-explorer repository?",
"...your-mcp-server-deployment-id...", # can also be list
deepseek_client,
model="deepseek-chat",
max_iterations=25
)
print("Response:", response)
asyncio.run(main())
```
### Streaming Chat
```python
import asyncio
from openai import AsyncOpenAI
from metorial import Metorial
from metorial.types import StreamEventType
async def streaming_example():
# Initialize clients
metorial = Metorial(api_key="...your-metorial-api-key...")
deepseek_client = AsyncOpenAI(
api_key="...your-deepseek-api-key...",
base_url="https://api.deepseek.com"
)
# Streaming chat with real-time responses
async def stream_action(session):
messages = [
{"role": "user", "content": "Explain quantum computing"}
]
async for event in metorial.stream(
deepseek_client, session, messages,
model="deepseek-chat",
max_iterations=25
):
if event.type == StreamEventType.CONTENT:
print(f"š¤ {event.content}", end="", flush=True)
elif event.type == StreamEventType.TOOL_CALL:
print(f"\nš§ Executing {len(event.tool_calls)} tool(s)...")
elif event.type == StreamEventType.COMPLETE:
print(f"\nā
Complete!")
await metorial.with_session("...your-server-deployment-id...", stream_action)
asyncio.run(streaming_example())
```
### Advanced Usage with Session Management
```python
import asyncio
from openai import OpenAI
from metorial import Metorial
from metorial_deepseek import MetorialDeepSeekSession
async def main():
# Initialize clients
metorial = Metorial(api_key="...your-metorial-api-key...")
# DeepSeek uses OpenAI-compatible client
deepseek_client = OpenAI(
api_key="...your-deepseek-api-key...",
base_url="https://api.deepseek.com"
)
# Create session with your server deployments
async with metorial.session(["...your-server-deployment-id..."]) as session:
# Create DeepSeek-specific wrapper
deepseek_session = MetorialDeepSeekSession(session.tool_manager)
messages = [
{"role": "user", "content": "What are the latest commits?"}
]
response = deepseek_client.chat.completions.create(
model="deepseek-chat",
messages=messages,
tools=deepseek_session.tools
)
# Handle tool calls
tool_calls = response.choices[0].message.tool_calls
if tool_calls:
tool_responses = await deepseek_session.call_tools(tool_calls)
# Add to conversation
messages.append({
"role": "assistant",
"tool_calls": tool_calls
})
messages.extend(tool_responses)
# Continue conversation...
asyncio.run(main())
```
### Using Convenience Functions
```python
from metorial_deepseek import build_deepseek_tools, call_deepseek_tools
async def example_with_functions():
# Get tools in DeepSeek format
tools = build_deepseek_tools(tool_manager)
# Call tools from DeepSeek response
tool_messages = await call_deepseek_tools(tool_manager, tool_calls)
```
## API Reference
### `MetorialDeepSeekSession`
Main session class for DeepSeek integration.
```python
session = MetorialDeepSeekSession(tool_manager)
```
**Properties:**
- `tools`: List of tools in OpenAI-compatible format
**Methods:**
- `async call_tools(tool_calls)`: Execute tool calls and return tool messages
### `build_deepseek_tools(tool_mgr)`
Build DeepSeek-compatible tool definitions.
**Returns:** List of tool definitions in OpenAI format
### `call_deepseek_tools(tool_mgr, tool_calls)`
Execute tool calls from DeepSeek response.
**Returns:** List of tool messages
## Tool Format
Tools are converted to OpenAI-compatible format (without strict mode):
```python
{
"type": "function",
"function": {
"name": "tool_name",
"description": "Tool description",
"parameters": {
"type": "object",
"properties": {...},
"required": [...]
}
}
}
```
## DeepSeek API Configuration
DeepSeek uses the OpenAI-compatible API format. Configure your client like this:
```python
from openai import OpenAI
client = OpenAI(
api_key="...your-deepseek-api-key...",
base_url="https://api.deepseek.com"
)
```
## Error Handling
```python
try:
tool_messages = await deepseek_session.call_tools(tool_calls)
except Exception as e:
print(f"Tool execution failed: {e}")
```
Tool errors are returned as tool messages with error content.
## License
MIT License - see [LICENSE](../../LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "metorial-deepseek",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "ai, deepseek, llm, metorial",
"author": null,
"author_email": "Metorial Team <support@metorial.com>",
"download_url": "https://files.pythonhosted.org/packages/be/b5/c11a9c732658d9a37058a2a9e7e5eceb5c36209548f18dd2b8c758890ec9/metorial_deepseek-1.0.4.tar.gz",
"platform": null,
"description": "# metorial-deepseek\n\nDeepSeek provider integration for Metorial.\n\n## Installation\n\n```bash\npip install metorial-deepseek\n# or\nuv add metorial-deepseek\n# or\npoetry add metorial-deepseek\n```\n\n## Features\n\n- \ud83e\udd16 **DeepSeek Integration**: Full support for DeepSeek Chat, DeepSeek Coder, and other models\n- \ud83d\udce1 **Session Management**: Automatic tool lifecycle handling\n- \ud83d\udd04 **Format Conversion**: Converts Metorial tools to OpenAI function format\n- \u26a1 **Async Support**: Full async/await support\n\n## Supported Models\n\nAll DeepSeek models available through their API:\n\n- `deepseek-chat`: General-purpose conversational model\n- `deepseek-coder`: Specialized for code-related tasks\n\n## Usage\n\n### Quick Start (Recommended)\n\n```python\nimport asyncio\nfrom openai import AsyncOpenAI\nfrom metorial import Metorial\n\nasync def main():\n # Initialize clients\n metorial = Metorial(api_key=\"...your-metorial-api-key...\") # async by default\n deepseek_client = AsyncOpenAI(\n api_key=\"...your-deepseek-api-key...\", \n base_url=\"https://api.deepseek.com\"\n )\n \n # One-liner chat with automatic session management\n response = await metorial.run(\n \"What are the latest commits in the metorial/websocket-explorer repository?\",\n \"...your-mcp-server-deployment-id...\", # can also be list\n deepseek_client,\n model=\"deepseek-chat\",\n max_iterations=25\n )\n \n print(\"Response:\", response)\n\nasyncio.run(main())\n```\n\n### Streaming Chat\n\n```python\nimport asyncio\nfrom openai import AsyncOpenAI\nfrom metorial import Metorial\nfrom metorial.types import StreamEventType\n\nasync def streaming_example():\n # Initialize clients\n metorial = Metorial(api_key=\"...your-metorial-api-key...\")\n deepseek_client = AsyncOpenAI(\n api_key=\"...your-deepseek-api-key...\",\n base_url=\"https://api.deepseek.com\"\n )\n \n # Streaming chat with real-time responses\n async def stream_action(session):\n messages = [\n {\"role\": \"user\", \"content\": \"Explain quantum computing\"}\n ]\n \n async for event in metorial.stream(\n deepseek_client, session, messages, \n model=\"deepseek-chat\",\n max_iterations=25\n ):\n if event.type == StreamEventType.CONTENT:\n print(f\"\ud83e\udd16 {event.content}\", end=\"\", flush=True)\n elif event.type == StreamEventType.TOOL_CALL:\n print(f\"\\n\ud83d\udd27 Executing {len(event.tool_calls)} tool(s)...\")\n elif event.type == StreamEventType.COMPLETE:\n print(f\"\\n\u2705 Complete!\")\n \n await metorial.with_session(\"...your-server-deployment-id...\", stream_action)\n\nasyncio.run(streaming_example())\n```\n\n### Advanced Usage with Session Management\n\n```python\nimport asyncio\nfrom openai import OpenAI\nfrom metorial import Metorial\nfrom metorial_deepseek import MetorialDeepSeekSession\n\nasync def main():\n # Initialize clients\n metorial = Metorial(api_key=\"...your-metorial-api-key...\")\n \n # DeepSeek uses OpenAI-compatible client\n deepseek_client = OpenAI(\n api_key=\"...your-deepseek-api-key...\",\n base_url=\"https://api.deepseek.com\"\n )\n \n # Create session with your server deployments\n async with metorial.session([\"...your-server-deployment-id...\"]) as session:\n # Create DeepSeek-specific wrapper\n deepseek_session = MetorialDeepSeekSession(session.tool_manager)\n \n messages = [\n {\"role\": \"user\", \"content\": \"What are the latest commits?\"}\n ]\n \n response = deepseek_client.chat.completions.create(\n model=\"deepseek-chat\",\n messages=messages,\n tools=deepseek_session.tools\n )\n \n # Handle tool calls\n tool_calls = response.choices[0].message.tool_calls\n if tool_calls:\n tool_responses = await deepseek_session.call_tools(tool_calls)\n \n # Add to conversation\n messages.append({\n \"role\": \"assistant\",\n \"tool_calls\": tool_calls\n })\n messages.extend(tool_responses)\n \n # Continue conversation...\n\nasyncio.run(main())\n```\n\n### Using Convenience Functions\n\n```python\nfrom metorial_deepseek import build_deepseek_tools, call_deepseek_tools\n\nasync def example_with_functions():\n # Get tools in DeepSeek format\n tools = build_deepseek_tools(tool_manager)\n \n # Call tools from DeepSeek response\n tool_messages = await call_deepseek_tools(tool_manager, tool_calls)\n```\n\n## API Reference\n\n### `MetorialDeepSeekSession`\n\nMain session class for DeepSeek integration.\n\n```python\nsession = MetorialDeepSeekSession(tool_manager)\n```\n\n**Properties:**\n- `tools`: List of tools in OpenAI-compatible format\n\n**Methods:**\n- `async call_tools(tool_calls)`: Execute tool calls and return tool messages\n\n### `build_deepseek_tools(tool_mgr)`\n\nBuild DeepSeek-compatible tool definitions.\n\n**Returns:** List of tool definitions in OpenAI format\n\n### `call_deepseek_tools(tool_mgr, tool_calls)`\n\nExecute tool calls from DeepSeek response.\n\n**Returns:** List of tool messages\n\n## Tool Format\n\nTools are converted to OpenAI-compatible format (without strict mode):\n\n```python\n{\n \"type\": \"function\",\n \"function\": {\n \"name\": \"tool_name\",\n \"description\": \"Tool description\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {...},\n \"required\": [...]\n }\n }\n}\n```\n\n## DeepSeek API Configuration\n\nDeepSeek uses the OpenAI-compatible API format. Configure your client like this:\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=\"...your-deepseek-api-key...\",\n base_url=\"https://api.deepseek.com\"\n)\n```\n\n## Error Handling\n\n```python\ntry:\n tool_messages = await deepseek_session.call_tools(tool_calls)\nexcept Exception as e:\n print(f\"Tool execution failed: {e}\")\n```\n\nTool errors are returned as tool messages with error content.\n\n## License\n\nMIT License - see [LICENSE](../../LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "DeepSeek provider for Metorial",
"version": "1.0.4",
"project_urls": {
"Documentation": "https://metorial.com/docs",
"Homepage": "https://metorial.com",
"Repository": "https://github.com/metorial/metorial-python"
},
"split_keywords": [
"ai",
" deepseek",
" llm",
" metorial"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2ff542c0218b7c1bc8781c1b72853fb5d861d0116c38d467e72d3f0fc32f30e6",
"md5": "4f3c43897fde885071e34c61ad2ee823",
"sha256": "5c7762d8e3b05e9b36c2dd8e778b584612429efa12b26901182b20cd96b9efcc"
},
"downloads": -1,
"filename": "metorial_deepseek-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4f3c43897fde885071e34c61ad2ee823",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 4973,
"upload_time": "2025-10-30T05:03:12",
"upload_time_iso_8601": "2025-10-30T05:03:12.973596Z",
"url": "https://files.pythonhosted.org/packages/2f/f5/42c0218b7c1bc8781c1b72853fb5d861d0116c38d467e72d3f0fc32f30e6/metorial_deepseek-1.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "beb5c11a9c732658d9a37058a2a9e7e5eceb5c36209548f18dd2b8c758890ec9",
"md5": "b6654e875dec4c875d9a5e31c55bca97",
"sha256": "58b2a3de69aa2ed64d74d68e2d25bcb7db361c587d05a0a9b66ee268982d6c9a"
},
"downloads": -1,
"filename": "metorial_deepseek-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "b6654e875dec4c875d9a5e31c55bca97",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 6029,
"upload_time": "2025-10-30T05:03:17",
"upload_time_iso_8601": "2025-10-30T05:03:17.301068Z",
"url": "https://files.pythonhosted.org/packages/be/b5/c11a9c732658d9a37058a2a9e7e5eceb5c36209548f18dd2b8c758890ec9/metorial_deepseek-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-30 05:03:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "metorial",
"github_project": "metorial-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "metorial-deepseek"
}