Skip to content

v0.3.0 - Universal Tool Calling & Interactive Documentation

Choose a tag to compare

@laurentvv laurentvv released this 17 Aug 22:02
· 12 commits to main since this release
ec81474

πŸš€ NexusAI-Client v0.3.0 β€” Universal Tool Calling & Interactive Documentation

πŸ“¦ PyPI Package: https://pypi.org/project/nexusai-client/0.3.0/
🌐 Interactive Documentation: https://nexus-ai-client-doc.vercel.app/
πŸ“š Integration Guide: INTEGRATION_GUIDE.md


🌟 Highlights of Version 0.3.0

Version 0.3.0 introduces Universal Tool Calling / Function Calling across all 10 supported AI providers, enabling production-grade autonomous agent loops (ReAct) with zero heavy SDK dependencies, along with official integration with our interactive documentation platform.

1. πŸ› οΈ Universal Tool Calling (Function Calling)

  • Standardized Data Models: ToolCall, FunctionDefinition, ToolDefinition adhering to the OpenAI JSON schema standard.
  • Multi-Turn Agent History: Support for role="tool", tool_call_id, and tool_calls in ChatMessage.
  • Universal Multi-Provider Protocol Translation:
    • OpenAI-Compatible Providers (Groq, Cerebras, Mistral, DeepSeek, Nvidia NIM, OpenRouter, OrcaRouter): Native tool schema forwarding and automated tool_calls response parsing.
    • Google Gemini REST API: Automatic bi-directional translation to Gemini's functionDeclarations / toolConfig and parsing of functionCall / functionResponse.
    • Cohere V2 REST API: Native tool schema integration and parsing.
  • Failover-Safe Tool Calls: AIGateway.auto_fallback() and FallbackGateway preserve all tool definitions during automatic zero-cost failovers.

2. 🌐 Interactive Documentation Platform

3. πŸ§ͺ Comprehensive Test Coverage

  • 6 new dedicated test suites covering all tool-calling serialization, execution, multi-turn history, and fallback scenarios.
  • 32/32 tests passing (100% pass rate).

πŸ“¦ Installation & Upgrade

# With pip
pip install --upgrade nexusai-client

# With uv (Recommended)
uv add --upgrade nexusai-client

# With poetry
poetry add nexusai-client@latest

πŸ’‘ Quick Example: Autonomous Agent Loop

import asyncio
import json
from nexusai_client import AIGateway, ChatMessage, FunctionDefinition, ToolDefinition

weather_tool = ToolDefinition(
    function=FunctionDefinition(
        name="get_weather",
        description="Get current temperature and conditions for a given city.",
        parameters={
            "type": "object",
            "properties": {
                "city": {"type": "string", "description": "City name, e.g. Tokyo, Paris"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
            },
            "required": ["city"],
        },
    )
)

async def main():
    async with AIGateway.auto_fallback() as client:
        messages = [ChatMessage(role="user", content="What is the weather in Tokyo?")]
        response = await client.chat(messages=messages, tools=[weather_tool])

        if response.has_tool_calls:
            # 1. Append assistant tool calls
            messages.append(ChatMessage(role="assistant", content=response.text, tool_calls=response.tool_calls))

            # 2. Append tool execution result (unified role="tool")
            for call in response.tool_calls:
                print(f"πŸ”§ Tool requested: {call.name} with {call.arguments}")
                messages.append(
                    ChatMessage(
                        role="tool",
                        name=call.name,
                        tool_call_id=call.id,
                        content=json.dumps({"temperature": 19, "condition": "Clear"}),
                    )
                )

            # 3. Get final synthesis
            final = await client.chat(messages=messages)
            print(f"πŸ€– Final Answer:\n{final.text}")

if __name__ == "__main__":
    asyncio.run(main())

πŸ”— Useful Links