Name | metorial-xai JSON |
Version |
1.0.0rc2
JSON |
| download |
home_page | None |
Summary | XAI (Grok) provider for Metorial |
upload_time | 2025-07-26 12:17:52 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT |
keywords |
ai
grok
llm
metorial
xai
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# metorial-xai
XAI (Grok) provider integration for Metorial - enables using Metorial tools with XAI's Grok models through OpenAI-compatible function calling.
## Installation
```bash
pip install metorial-xai
# or
uv add metorial-xai
# or
poetry add metorial-xai
```
## Features
- 🤖 **Grok Integration**: Full support for Grok models through XAI API
- 🛠️ **Function Calling**: OpenAI-compatible function calling support
- 📡 **Session Management**: Automatic tool lifecycle handling
- 🔄 **Format Conversion**: Converts Metorial tools to OpenAI function format
- ✅ **Strict Mode**: Built-in strict parameter validation
- ⚡ **Async Support**: Full async/await support
## Usage
### Basic Usage
```python
import asyncio
from openai import OpenAI
from metorial import Metorial
from metorial_xai import MetorialXAISession
async def main():
# Initialize clients
metorial = Metorial(api_key="your-metorial-api-key")
# XAI uses OpenAI-compatible client
xai_client = OpenAI(
api_key="your-xai-api-key",
base_url="https://api.x.ai/v1"
)
# Create session with your server deployments
async with metorial.session(["your-server-deployment-id"]) as session:
# Create XAI-specific wrapper
xai_session = MetorialXAISession(session.tool_manager)
messages = [
{"role": "user", "content": "What are the latest commits?"}
]
response = xai_client.chat.completions.create(
model="grok-beta",
messages=messages,
tools=xai_session.tools
)
# Handle tool calls
tool_calls = response.choices[0].message.tool_calls
if tool_calls:
tool_responses = await xai_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_xai import build_xai_tools, call_xai_tools
async def example_with_functions():
# Get tools in XAI format
tools = build_xai_tools(tool_manager)
# Call tools from XAI response
tool_messages = await call_xai_tools(tool_manager, tool_calls)
```
## API Reference
### `MetorialXAISession`
Main session class for XAI integration.
```python
session = MetorialXAISession(tool_manager)
```
**Properties:**
- `tools`: List of tools in OpenAI-compatible format with strict mode
**Methods:**
- `async call_tools(tool_calls)`: Execute tool calls and return tool messages
### `build_xai_tools(tool_mgr)`
Build XAI-compatible tool definitions.
**Returns:** List of tool definitions in OpenAI format with strict mode
### `call_xai_tools(tool_mgr, tool_calls)`
Execute tool calls from XAI response.
**Returns:** List of tool messages
## Tool Format
Tools are converted to OpenAI-compatible format with strict mode enabled:
```python
{
"type": "function",
"function": {
"name": "tool_name",
"description": "Tool description",
"parameters": {
"type": "object",
"properties": {...},
"required": [...]
},
"strict": True
}
}
```
## XAI API Configuration
XAI uses the OpenAI-compatible API format. Configure your client like this:
```python
from openai import OpenAI
client = OpenAI(
api_key="your-xai-api-key",
base_url="https://api.x.ai/v1"
)
```
## Error Handling
```python
try:
tool_messages = await xai_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.
## Dependencies
- `metorial-openai-compatible>=1.0.0`
- `metorial-mcp-session>=1.0.0`
- `typing-extensions>=4.0.0`
## License
MIT License - see [LICENSE](../../LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "metorial-xai",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "ai, grok, llm, metorial, xai",
"author": null,
"author_email": "Metorial Team <support@metorial.com>",
"download_url": "https://files.pythonhosted.org/packages/e4/65/e6698c56f3a7d2969f185d3d70d5311a95c6118ea26bacaea6c2cf1a2d07/metorial_xai-1.0.0rc2.tar.gz",
"platform": null,
"description": "# metorial-xai\n\nXAI (Grok) provider integration for Metorial - enables using Metorial tools with XAI's Grok models through OpenAI-compatible function calling.\n\n## Installation\n\n```bash\npip install metorial-xai\n# or\nuv add metorial-xai\n# or\npoetry add metorial-xai\n```\n\n## Features\n\n- \ud83e\udd16 **Grok Integration**: Full support for Grok models through XAI API\n- \ud83d\udee0\ufe0f **Function Calling**: OpenAI-compatible function calling support\n- \ud83d\udce1 **Session Management**: Automatic tool lifecycle handling\n- \ud83d\udd04 **Format Conversion**: Converts Metorial tools to OpenAI function format\n- \u2705 **Strict Mode**: Built-in strict parameter validation\n- \u26a1 **Async Support**: Full async/await support\n\n## Usage\n\n### Basic Usage\n\n```python\nimport asyncio\nfrom openai import OpenAI\nfrom metorial import Metorial\nfrom metorial_xai import MetorialXAISession\n\nasync def main():\n # Initialize clients\n metorial = Metorial(api_key=\"your-metorial-api-key\")\n \n # XAI uses OpenAI-compatible client\n xai_client = OpenAI(\n api_key=\"your-xai-api-key\",\n base_url=\"https://api.x.ai/v1\"\n )\n \n # Create session with your server deployments\n async with metorial.session([\"your-server-deployment-id\"]) as session:\n # Create XAI-specific wrapper\n xai_session = MetorialXAISession(session.tool_manager)\n \n messages = [\n {\"role\": \"user\", \"content\": \"What are the latest commits?\"}\n ]\n \n response = xai_client.chat.completions.create(\n model=\"grok-beta\",\n messages=messages,\n tools=xai_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 xai_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_xai import build_xai_tools, call_xai_tools\n\nasync def example_with_functions():\n # Get tools in XAI format\n tools = build_xai_tools(tool_manager)\n \n # Call tools from XAI response\n tool_messages = await call_xai_tools(tool_manager, tool_calls)\n```\n\n## API Reference\n\n### `MetorialXAISession`\n\nMain session class for XAI integration.\n\n```python\nsession = MetorialXAISession(tool_manager)\n```\n\n**Properties:**\n- `tools`: List of tools in OpenAI-compatible format with strict mode\n\n**Methods:**\n- `async call_tools(tool_calls)`: Execute tool calls and return tool messages\n\n### `build_xai_tools(tool_mgr)`\n\nBuild XAI-compatible tool definitions.\n\n**Returns:** List of tool definitions in OpenAI format with strict mode\n\n### `call_xai_tools(tool_mgr, tool_calls)`\n\nExecute tool calls from XAI response.\n\n**Returns:** List of tool messages\n\n## Tool Format\n\nTools are converted to OpenAI-compatible format with strict mode enabled:\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 \"strict\": True\n }\n}\n```\n\n## XAI API Configuration\n\nXAI 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-xai-api-key\",\n base_url=\"https://api.x.ai/v1\"\n)\n```\n\n## Error Handling\n\n```python\ntry:\n tool_messages = await xai_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## Dependencies\n\n- `metorial-openai-compatible>=1.0.0`\n- `metorial-mcp-session>=1.0.0`\n- `typing-extensions>=4.0.0`\n\n## License\n\nMIT License - see [LICENSE](../../LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "XAI (Grok) provider for Metorial",
"version": "1.0.0rc2",
"project_urls": {
"Documentation": "https://metorial.com/docs",
"Homepage": "https://metorial.com",
"Repository": "https://github.com/metorial/metorial-enterprise"
},
"split_keywords": [
"ai",
" grok",
" llm",
" metorial",
" xai"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c53b416dc4ffb45aa44781e43f0ad07d5d0100726ad328e0e67547f83519d460",
"md5": "7c6829f5d34eb01bbddcd37e31ce68a6",
"sha256": "7dd4d1d4da42e94e73e0796d840b7e1d7aa3ad0b4c47599feaac6a5b4d84187f"
},
"downloads": -1,
"filename": "metorial_xai-1.0.0rc2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7c6829f5d34eb01bbddcd37e31ce68a6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 4264,
"upload_time": "2025-07-26T12:17:46",
"upload_time_iso_8601": "2025-07-26T12:17:46.144970Z",
"url": "https://files.pythonhosted.org/packages/c5/3b/416dc4ffb45aa44781e43f0ad07d5d0100726ad328e0e67547f83519d460/metorial_xai-1.0.0rc2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e465e6698c56f3a7d2969f185d3d70d5311a95c6118ea26bacaea6c2cf1a2d07",
"md5": "1bff9caee4cd8d8da7b2edbcf5268dd8",
"sha256": "be111b3b6f307d3db37c5ac88ae7a44530d2adff2e16bf2b996dd47e69ac53e4"
},
"downloads": -1,
"filename": "metorial_xai-1.0.0rc2.tar.gz",
"has_sig": false,
"md5_digest": "1bff9caee4cd8d8da7b2edbcf5268dd8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 5375,
"upload_time": "2025-07-26T12:17:52",
"upload_time_iso_8601": "2025-07-26T12:17:52.510860Z",
"url": "https://files.pythonhosted.org/packages/e4/65/e6698c56f3a7d2969f185d3d70d5311a95c6118ea26bacaea6c2cf1a2d07/metorial_xai-1.0.0rc2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-26 12:17:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "metorial",
"github_project": "metorial-enterprise",
"github_not_found": true,
"lcname": "metorial-xai"
}