Creates a new AI model configuration
Initializes a model configuration with the specified parameters and settings. The model configuration defines how the AI model behaves and interacts with the platform.
Configuration data including: - name: Model configuration name - provider: AI provider (e.g., 'openai', 'anthropic') - model_id: Provider's model identifier - temperature: Response randomness (0-1) - max_tokens: Maximum response length - metadata: Custom metadata object
Optionaluri: stringOptional custom URI path for the model endpoint
Get the chat functionality for this model
This getter provides access to the model's chat capabilities through the Chat class. It enables direct interaction with the model for text generation and completion tasks.
A new Chat instance configured for this model
Basic chat:
const response = await model.chat.completions.create({
messages: [
{ role: 'user', content: 'What is machine learning?' }
]
});
Advanced chat with system prompt:
const response = await model.chat.completions.create({
messages: [
{
role: 'system',
content: 'You are an expert in artificial intelligence.'
},
{
role: 'user',
content: 'Explain neural networks to a beginner.'
}
],
temperature: 0.3,
max_tokens: 1000,
stream: false
});
console.log('Model explanation:', response.choices[0].message.content);
Check if the entity is active
This method checks the active status of the entity. Most entities in the system can be active or inactive, which affects their availability and usability in the platform.
True if the entity is active, false otherwise
Convert model instance to interface data
This method serializes the model instance to a plain object that matches the interface type. This is useful for:
The model data as a plain object matching the interface type
Convert model instance to API payload
This method creates a payload suitable for API requests by:
A clean object suitable for API requests
Update model data with new values
This method updates the model's data and instance properties with new values. It performs a shallow merge of the updates with existing data, allowing for partial updates of the model's properties.
Object containing properties to update
const user = new User({
email: 'old@example.com',
firstName: 'John'
});
// Update multiple properties
user.update({
email: 'new@example.com',
lastName: 'Doe'
});
// Save changes to API
await user.save();
This method only updates the local model instance. To persist changes to the API, call save after updating.
Save the model instance to the API
This method persists the current state of the model to the API using a PUT request. It requires the model to have an ID (existing instance). For new instances, use the collection's create method instead.
The method:
Promise resolving to the updated model data
Delete the model instance from the API
This method permanently deletes the model instance from the API and clears the local data. This operation cannot be undone.
The method:
Promise that resolves when deletion is successful
Rerank documents using this model
Uses this model to rerank documents based on their relevance to a query string.
Rerank request parameters
Rerank request interface
Promise resolving to the rerank response
Generate embeddings using this model
Generates vector embeddings for text input using this model.
Embedding request parameters
Embedding request interface
Promise resolving to the embedding response
Like or unlike this model
Toggles the like status of this model. If the model is already liked, it will be unliked, and vice versa.
Promise that resolves to the updated model instance
Model class for managing AI model configurations
This class represents an AI model configuration in the Mosaia platform. It provides a structured way to define, customize, and interact with various AI models through a unified interface.
Features:
Remarks
Models are the core AI engines that power:
The class supports various model providers and configurations:
Example
Basic model setup:
Example
Using chat capabilities: