forked from github/codespaces-models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.js
30 lines (23 loc) · 823 Bytes
/
basic.js
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
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?" }
],
model: modelName,
// Optional parameters
temperature: 1.,
max_tokens: 1000,
top_p: 1.
});
console.log(response.choices[0].message.content);
}
main().catch((err) => {
console.error("The sample encountered an error:", err);
});