tomasmcm's picture
Update index.js
da0da75 verified
import TeapotAI from './TeapotAI.js';
const context = `
The Eiffel Tower is a wrought iron lattice tower in Paris, France. It was designed by Gustave Eiffel and completed in 1889.
It stands at a height of 330 meters and is one of the most recognizable structures in the world.
`;
const query = "What is the height of the Eiffel Tower?";
const conversation = [
{ content: "user: Hi there! Can you tell me about the capital of France?" },
{ content: "agent: Hello! The capital of France is Paris. It's known for landmarks like the Eiffel Tower and the Louvre Museum." },
{ content: "user: What's the weather like there today?" }
];
async function main() {
try {
const teapotAI = new TeapotAI({
modelId: 'tomasmcm/teapotai-teapotllm-onnx',
pipelineOptions: {
dtype: 'q4'
}
});
await teapotAI.initialize();
// --- Example 1: Query Method ---
console.log("\n--- Running Query Example ---");
const queryAnswer = await teapotAI.query(query, context);
console.log("\nQuery Answer:");
console.log(queryAnswer);
// --- Example 2: Chat Method ---
if (teapotAI.verbose) console.log("\n--- Running Chat Example ---");
const chatResponse = await teapotAI.chat(conversation);
console.log("\nChat Response:");
console.log(chatResponse);
} catch (error) {
console.error("\n--- An error occurred ---");
console.error(error);
}
}
main();