Repository navigation
v1.7.2
1.7.2 (2026-03-20)
Breaking change
ResilientLLM.chat()now always returns a consistent envelope object:{ content, toolCalls?, metadata }(metadata is no longer gated byreturnOperationMetadata).
This is how you use the library after v1.7.2
import { ResilientLLM } from 'resilient-llm';
const llm = new ResilientLLM({
aiService: 'openai',
model: 'gpt-4o-mini',
});
const conversationHistory = [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'assistant', content: 'Hi, I am here to help.' },
{ role: 'user', content: 'What is the capital of France?' }
];
try {
const { content, toolCalls, metadata } = await llm.chat(conversationHistory);
console.log('LLM response:', content);
} catch (err) {
console.error('Error:', err);
}Bug Fixes
Structured output example
const conversationHistory = [{ role: 'user', content: 'Add 2 and 3 and respond ONLY with JSON having sum and explanationSteps' }];
const { content: result } = await llm.chat(conversationHistory, {
responseFormat: {
type: 'json_schema',
json_schema: {
name: 'math_answer',
schema: {
type: 'object',
properties: {
sum: { type: 'number' },
explanationSteps: {
type: 'array',
items: { type: 'string' }
}
},
required: ['sum', 'explanationSteps'],
// Anthropic Messages structured output requires explicit false here for object roots.
additionalProperties: false
}
}
});
console.log(JSON.stringify(result))
// {
// content: {
// sum: 5,
// explanationSteps: [
// "Add 2 and 3.",
// "The result is 5."
// ]
// },
// metadata: { requestId: "unique-id", finishReason: "stop", .... }
// }