| title | AI Integration Quick Start |
|---|---|
| description | Quick guide to integrating AI features into ObjectStack applications |
Quick guide to integrating AI features into ObjectStack applications
ObjectStack provides built-in AI capabilities through the AI Protocol. This guide covers the essentials.
const agent = {
name: 'sales_assistant',
label: 'Sales Assistant',
model: {
provider: 'openai',
modelName: 'gpt-4',
temperature: 0.7,
},
tools: [
'query_records',
'create_record',
'send_email',
],
systemPrompt: 'You are a helpful sales assistant...',
};const modelRegistry = {
models: [
{
id: 'gpt-4',
provider: 'openai',
capabilities: ['chat', 'function_calling'],
limits: {
maxTokens: 8192,
maxContextLength: 128000,
},
},
],
};const ragConfig = {
knowledgeBases: ['product_docs', 'sales_playbook'],
chunking: {
strategy: 'semantic',
chunkSize: 512,
overlap: 50,
},
embedding: {
model: 'text-embedding-ada-002',
provider: 'openai',
},
vectorStore: {
provider: 'pinecone',
config: {
apiKey: process.env.PINECONE_API_KEY,
environment: 'production',
},
},
retrieval: {
topK: 5,
minScore: 0.7,
},
};const nlqConfig = {
enabled: true,
objects: ['customer_account', 'opportunity'],
fieldMappings: [
{
synonyms: ['revenue', 'sales', 'income'],
field: 'annual_revenue',
},
{
synonyms: ['company', 'business', 'organization'],
field: 'account_name',
},
],
examples: [
{
query: 'show me high value customers',
intent: 'list',
filters: [{ field: 'annual_revenue', operator: 'gt', value: 1000000 }],
},
],
};const result = await ai.query({
prompt: 'Show me all accounts in the technology industry with revenue over $1M',
object: 'customer_account',
});
// Returns: QueryResult with structured dataconst generated = await ai.generate({
prompt: 'Write a follow-up email for this customer',
context: {
customer: customerData,
lastInteraction: interactionData,
},
});-
Prompt Engineering
- Be specific and clear
- Provide context
- Use examples
-
Model Selection
- Use appropriate model for task
- Balance cost vs. capability
- Consider latency requirements
-
RAG Optimization
- Chunk documents semantically
- Use appropriate embedding models
- Filter results by relevance score
-
Error Handling
- Handle model failures gracefully
- Implement retry logic
- Provide fallbacks
See the following example implementations:
For complete documentation, see AI_INTEGRATION_GUIDE.md
Last Updated: 2026-01-22