File size: 1,427 Bytes
e9f1d21 da0da75 e9f1d21 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
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(); |