generated from github/codespaces-models
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_turn.js
More file actions
28 lines (21 loc) · 855 Bytes
/
multi_turn.js
File metadata and controls
28 lines (21 loc) · 855 Bytes
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
import OpenAI from "openai";
const token = process.env["GITHUB_TOKEN"];
const endpoint = "https://models.inference.ai.azure.com";
/* Pick one of the Azure OpenAI models from the GitHub Models service */
const modelName = "gpt-4o-mini";
export async function main() {
const client = new OpenAI({ baseURL: endpoint, apiKey: token });
const response = await client.chat.completions.create({
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" },
{ role: "assistant", content: "The capital of France is Paris." },
{ role: "user", content: "What about Spain?" }
],
model: modelName
});
console.log(response.choices[0].message.content);
}
main().catch((err) => {
console.error("The sample encountered an error:", err);
});