mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-23 07:45:27 -04:00
16 lines
409 B
TypeScript
16 lines
409 B
TypeScript
import { OpenAI } from "llamaindex";
|
|
|
|
(async () => {
|
|
const llm = new OpenAI({ model: "gpt-4-turbo", temperature: 0.1 });
|
|
|
|
// complete api
|
|
const response1 = await llm.complete({ prompt: "How are you?" });
|
|
console.log(response1.text);
|
|
|
|
// chat api
|
|
const response2 = await llm.chat({
|
|
messages: [{ content: "Tell me a joke!", role: "user" }],
|
|
});
|
|
console.log(response2.message.content);
|
|
})();
|