While xpander.ai offers a serverless solution where you can use AI agents without managing LLM infrastructure, you might want to use your own LLM deployment for:

  • Running models locally for lower latency
  • Using specific model versions or custom fine-tuned models
  • Implementing local function calling
  • Maintaining full control over your LLM stack
  • Handling sensitive data locally

This guide shows how to integrate your LLM with xpander’s tools and local functions.

Choose Your LLM Provider

To integrate your LLM with xpander’s tools and local functions, you’ll need to select one LLM provider and model combination. The integration is done by configuring your agent object with the chosen provider and model.

Provider and Model Selection

You can specify your chosen LLM provider and model using either enums from the SDK or string values:

from xpander_sdk import (
    LLMProvider,  # Enum for supported LLM providers
    OpenAISupportedModels,  # Enum for Function calling LLMs
    NvidiaNIMSupportedModels,
    OllamaSupportedModels,
    AmazonBedrockSupportedModels
)

Get Tools to the LLM

Run Tools for the LLM

Available Providers and Models

Here are all the supported LLM providers and their corresponding models. Choose the combination that best fits your needs:

FrameworkModel NameModel Identifier (String)
Amazon BedrockAnthropocene Claude 3 Haikuanthropic.claude-3-haiku-20240307-v1:0
Anthropocene Claude 3.5 Sonnetanthropic.claude-3-5-sonnet-20240620-v1:0
Cohere Command Rcohere.command-r-v1:0
Cohere Command R Pluscohere.command-r-plus-v1:0
Meta Llama 3 1.8B Instructmeta.llama3-1-8b-instruct-v1:0
Meta Llama 3 1.70B Instructmeta.llama3-1-70b-instruct-v1:0
Meta Llama 3 1.405B Instructmeta.llama3-1-405b-instruct-v1:0
Mistral Large 2402mistral.mistral-large-2402-v1:0
Mistral Large 2407mistral.mistral-large-2407-v1:0
Mistral Small 2402mistral.mistral-small-2402-v1:0
Nvidia NIMMeta Llama 3.1 70B Instructmeta/llama-3.1-70b-instruct
OllamaQwen2.5-Coderqwen2.5-coder
OpenAIOpenAI GPT-4gpt-4
OpenAI GPT-4ogpt-4o
OpenAI GPT-4o Minigpt-4o-mini

Tool Response

The tool_response object represents the output from a tool invoked by an AI Agent. It contains key attributes that provide information about the tool invocation’s execution and results. This data is used to build the AI Agent’s memory and guide further interactions.

Tool Response Object Structure

AttributeTypeDescription
function_namestrThe name of the invoked function or tool.
status_codeintThe HTTP status code returned by the tool or system.
resultdictThe actual response or output from the tool.
payloaddictThe data payload generated by the AI for the tool invocation.
tool_call_idstrA unique identifier for the specific tool invocation.

Full example

Best Practices

  1. Error Handling: Implement robust error handling for both LLM and tool calls
  2. Memory Management: Properly manage conversation context
  3. Security: Validate all inputs and file operations
  4. Monitoring: Log LLM and tool performance metrics
  5. Testing: Test with different prompts and tool combinations

Need help? Visit our Discord community or documentation.