WeaviateEx.API.GenerativeConfig (WeaviateEx v0.7.4)
View SourceConfiguration builders for Weaviate generative search (RAG) providers.
This module provides helper functions to configure generative AI modules for collection schema definitions. These configurations enable RAG (Retrieval Augmented Generation) capabilities on collections.
Supported Providers
- OpenAI - GPT-4, GPT-3.5, O1/O3 models
- Azure OpenAI - Azure-hosted OpenAI models
- Anthropic - Claude 3.5 Sonnet, Claude 3 Opus/Haiku
- Cohere - Command R/R+ models
- Mistral - Mistral Large, Medium models
- Google - Gemini Pro, PaLM models
- AWS - Bedrock/SageMaker hosted models
- Ollama - Self-hosted models
- Databricks - Foundation Model APIs
- NVIDIA - NIM models
- FriendliAI - Serverless inference
- XAI - Grok models
- Anyscale - Endpoints
- ContextualAI - Grounded generation
Examples
# Configure OpenAI for a collection
config = GenerativeConfig.openai(model: "gpt-4")
Collections.create("Article", %{
properties: [...],
generative_config: config
})
# Configure Anthropic with options
config = GenerativeConfig.anthropic(
model: "claude-3-5-sonnet-latest",
temperature: 0.7,
max_tokens: 4096
)
# Configure Ollama for local inference
config = GenerativeConfig.ollama(
model: "llama3",
api_endpoint: "http://localhost:11434"
)
Summary
Functions
Create Anthropic generative configuration.
Create Anyscale generative configuration.
Create AWS (Bedrock/SageMaker) generative configuration.
Create Azure OpenAI generative configuration.
Create Cohere generative configuration.
Create ContextualAI generative configuration.
Create a configuration for a custom/unlisted generative provider.
Create Databricks generative configuration.
Create FriendliAI generative configuration.
Create Google (Gemini/PaLM) generative configuration.
Create Mistral generative configuration.
Create NVIDIA NIM generative configuration.
Create Ollama generative configuration.
Create OpenAI generative configuration.
Get the Weaviate module name for a provider.
List all supported generative providers.
Create XAI (Grok) generative configuration.
Types
Functions
Create Anthropic generative configuration.
Options
:model- Model name (e.g., "claude-3-5-sonnet-latest"):temperature- Sampling temperature:max_tokens- Maximum tokens to generate:top_k- Top-k sampling parameter:top_p- Top-p (nucleus) sampling parameter
Examples
GenerativeConfig.anthropic(model: "claude-3-5-sonnet-latest")
GenerativeConfig.anthropic(
model: "claude-3-opus-20240229",
temperature: 0.7,
max_tokens: 4096
)
Create Anyscale generative configuration.
Options
:model- Model name (e.g., "meta-llama/Llama-3-70b-chat-hf"):base_url- Custom API endpoint URL:temperature- Sampling temperature
Examples
GenerativeConfig.anyscale(model: "meta-llama/Llama-3-70b-chat-hf")
Create AWS (Bedrock/SageMaker) generative configuration.
Options
:model- Model ID (e.g., "anthropic.claude-v2"):region- AWS region:service- AWS service ("bedrock" or "sagemaker"):temperature- Sampling temperature:max_tokens- Maximum tokens to generate
Examples
GenerativeConfig.aws(
model: "anthropic.claude-v2",
region: "us-east-1"
)
GenerativeConfig.aws(
model: "anthropic.claude-v2",
region: "us-west-2",
service: "bedrock"
)
Create Azure OpenAI generative configuration.
Options
:resource_name- Azure resource name (required):deployment_id- Deployment ID (required):temperature- Sampling temperature:max_tokens- Maximum tokens to generate
Examples
GenerativeConfig.azure_openai(
resource_name: "my-resource",
deployment_id: "gpt-4-deployment"
)
Create Cohere generative configuration.
Options
:model- Model name (e.g., "command-r-plus", "command-r"):temperature- Sampling temperature:max_tokens- Maximum tokens to generate:k- Top-k sampling parameter:p- Top-p (nucleus) sampling parameter
Examples
GenerativeConfig.cohere(model: "command-r-plus")
GenerativeConfig.cohere(
model: "command-r",
temperature: 0.8,
k: 5
)
Create ContextualAI generative configuration.
Options
:model- Model name (optional)
Examples
GenerativeConfig.contextualai()
GenerativeConfig.contextualai(model: "grounded-generation")
Create a configuration for a custom/unlisted generative provider.
Use this when connecting to a generative AI provider not natively supported by Weaviate. All options are passed through with automatic camelCase conversion.
Arguments
name- Identifier for the custom provider (for your reference)opts- Provider configuration options
Common Options
:api_endpoint- API endpoint URL (required for most providers):model- Model identifier:api_key_header- Header name for API key authentication:base_url- Base URL for the API
Any additional options are passed through with snake_case to camelCase conversion.
Examples
# Custom LLM endpoint
GenerativeConfig.custom("my-llm",
api_endpoint: "https://my-llm.example.com/v1/generate",
model: "custom-model-v1"
)
# Local LLM
GenerativeConfig.custom("local-ollama",
api_endpoint: "http://localhost:11434",
model: "llama2"
)
# Enterprise LLM with custom auth header
GenerativeConfig.custom("enterprise-llm",
api_endpoint: "https://llm.enterprise.com/api",
model: "enterprise-gpt",
api_key_header: "X-API-Key"
)
Create Databricks generative configuration.
Options
:endpoint- Databricks serving endpoint URL (required):temperature- Sampling temperature:max_tokens- Maximum tokens to generate:top_k- Top-k sampling parameter:top_p- Top-p (nucleus) sampling parameter
Examples
GenerativeConfig.databricks(
endpoint: "https://my-workspace.cloud.databricks.com"
)
Create FriendliAI generative configuration.
Options
:model- Model name:base_url- Custom API endpoint URL:temperature- Sampling temperature:max_tokens- Maximum tokens to generate
Examples
GenerativeConfig.friendliai(model: "mixtral-8x7b")
Create Google (Gemini/PaLM) generative configuration.
Options
:model- Model name (e.g., "gemini-pro", "gemini-1.5-pro"):temperature- Sampling temperature:max_tokens- Maximum tokens to generate:project_id- GCP project ID
Examples
GenerativeConfig.google(model: "gemini-1.5-pro")
GenerativeConfig.google(
model: "gemini-pro",
project_id: "my-gcp-project"
)
Create Mistral generative configuration.
Options
:model- Model name (e.g., "mistral-large-latest"):temperature- Sampling temperature:max_tokens- Maximum tokens to generate:base_url- Custom API endpoint URL
Examples
GenerativeConfig.mistral(model: "mistral-large-latest")
Create NVIDIA NIM generative configuration.
Options
:model- Model name (e.g., "meta/llama-3.1-405b-instruct"):base_url- Custom API endpoint URL:temperature- Sampling temperature:max_tokens- Maximum tokens to generate
Examples
GenerativeConfig.nvidia(model: "meta/llama-3.1-405b-instruct")
Create Ollama generative configuration.
Options
:model- Model name (e.g., "llama3", "mistral"):api_endpoint- Ollama API endpoint URL:temperature- Sampling temperature
Examples
GenerativeConfig.ollama(model: "llama3")
GenerativeConfig.ollama(
model: "llama3:70b",
api_endpoint: "http://localhost:11434"
)
Create OpenAI generative configuration.
Options
:model- Model name (e.g., "gpt-4", "gpt-3.5-turbo"):temperature- Sampling temperature (0.0-2.0):max_tokens- Maximum tokens to generate:base_url- Custom API endpoint URL
Examples
GenerativeConfig.openai(model: "gpt-4")
GenerativeConfig.openai(
model: "gpt-4-turbo",
temperature: 0.7,
max_tokens: 1000
)
Get the Weaviate module name for a provider.
Examples
GenerativeConfig.provider_module(:openai)
# => "generative-openai"
GenerativeConfig.provider_module(:google)
# => "generative-palm"
@spec providers() :: [provider()]
List all supported generative providers.
Examples
GenerativeConfig.providers()
# => [:openai, :anthropic, :cohere, ...]
Create XAI (Grok) generative configuration.
Options
:model- Model name (e.g., "grok-2"):temperature- Sampling temperature:max_tokens- Maximum tokens to generate:base_url- Custom API endpoint URL
Examples
GenerativeConfig.xai(model: "grok-2")