Documentation Index
Fetch the complete documentation index at: https://docs.goantiai.com/llms.txt
Use this file to discover all available pages before exploring further.
LangChain Integration
import { OculusClient } from '@oculus/sdk';
import { DynamicTool } from 'langchain/tools';
import { ChatOpenAI } from 'langchain/chat_models/openai';
import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
const oculus = new OculusClient({
clientId: process.env.AGENT_CLIENT_ID!,
clientSecret: process.env.AGENT_CLIENT_SECRET!,
});
const tools = [
new DynamicTool({
name: 'read_customer_data',
description: 'Read customer data from the database',
func: async (customerId: string) => {
const token = await oculus.getToken('db:read');
const resp = await fetch(`https://api.myservice.com/customers/${customerId}`, {
headers: { Authorization: `Bearer ${token}` },
});
return JSON.stringify(await resp.json());
},
}),
new DynamicTool({
name: 'process_payment',
description: 'Process a payment for a customer',
func: async (input: string) => {
const { amount, currency } = JSON.parse(input);
const token = await oculus.getToken('stripe:charge:write');
const resp = await fetch('https://api.stripe.com/v1/charges', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ amount, currency }),
});
return JSON.stringify(await resp.json());
},
}),
];
const llm = new ChatOpenAI({ modelName: 'gpt-4o' });
const agent = await createOpenAIFunctionsAgent({ llm, tools, prompt: /* your prompt */ });
const executor = new AgentExecutor({ agent, tools });
const result = await executor.invoke({
input: 'Process a $50 payment for customer cus_123',
});
Each tool requests only the scope it needs. read_customer_data uses db:read; process_payment uses stripe:charge:write. This is the least-privilege pattern — each operation gets exactly the access it needs, nothing more.