-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodels.py
More file actions
37 lines (30 loc) · 950 Bytes
/
Copy pathmodels.py
File metadata and controls
37 lines (30 loc) · 950 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
29
30
31
32
33
34
35
36
37
import ModelClient, { isUnexpected } from "@azure-rest/ai-inference";
import { AzureKeyCredential } from "@azure/core-auth";
const token = process.env["GITHUB_TOKEN"];
const endpoint = "https://models.github.ai/inference";
const modelName = "meta/Meta-Llama-3.1-8B-Instruct";
export async function main() {
const client = ModelClient(
endpoint,
new AzureKeyCredential(token),
);
const response = await client.path("/chat/completions").post({
body: {
messages: [
{ role:"system", content: "You are a helpful assistant." },
{ role:"user", content: "What is the capital of France?" }
],
temperature: 1.0,
top_p: 1.0,
max_tokens: 1000,
model: modelName
}
});
if (isUnexpected(response)) {
throw response.body.error;
}
console.log(response.body.choices[0].message.content);
}
main().catch((err) => {
console.error("The sample encountered an error:", err);
});