Skip to content

Commit

Permalink
fix: use gpt-4o as default model (#63)
Browse files Browse the repository at this point in the history
this aligns with other uses across github
  • Loading branch information
gr2m authored Sep 9, 2024
1 parent 43a5e4e commit 2b49829
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
4 changes: 1 addition & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export type CreateConfirmationEventOptions = {
};

export interface CreateConfirmationEventInterface {
(
options: CreateConfirmationEventOptions,
): string;
(options: CreateConfirmationEventOptions): string;
}
export interface CreateReferencesEventInterface {
(references: CopilotReference[]): string;
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export async function promptTest() {
await prompt("What is the capital of France?", {
token: "secret",
request: {
fetch: () => { },
fetch: () => {},
},
});

Expand Down
10 changes: 5 additions & 5 deletions lib/prompt.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// @ts-check

/** @type {import('..').PromptInterface} */
const DEFAULT_ENDPOINT = "https://api.githubcopilot.com/chat/completions";
const DEFAULT_MODEL = "gpt-4o";

/** @type {import('..').PromptInterface} */
function parsePromptArguments(userPrompt, promptOptions) {
const { request: requestOptions, ...options } =
typeof userPrompt === "string" ? promptOptions : userPrompt;

const promptFetch = requestOptions?.fetch || fetch;
const model = options.model || "gpt-4";
const endpoint =
options.endpoint || "https://api.githubcopilot.com/chat/completions";
const model = options.model || DEFAULT_MODEL;
const endpoint = options.endpoint || DEFAULT_ENDPOINT;

const systemMessage = options.tools
? "You are a helpful assistant. Use the supplied tools to assist the user."
Expand Down Expand Up @@ -58,7 +59,6 @@ async function sendPromptRequest(promptFetch, options) {
}

const body = await response.text();
console.log({ body });

throw Object.assign(
new Error(
Expand Down
14 changes: 7 additions & 7 deletions test/prompt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ suite("prompt", () => {
content: "What is the capital of France?",
},
],
model: "gpt-4",
model: "gpt-4o",
}),
})
.reply(
Expand Down Expand Up @@ -152,7 +152,7 @@ suite("prompt", () => {
{ role: "assistant", content: "The capital of France is Paris." },
{ role: "user", content: "What about Spain?" },
],
model: "gpt-4",
model: "gpt-4o",
}),
})
.reply(
Expand Down Expand Up @@ -216,7 +216,7 @@ suite("prompt", () => {
content: "What is the capital of France?",
},
],
model: "gpt-4",
model: "gpt-4o",
}),
})
.reply(
Expand Down Expand Up @@ -273,7 +273,7 @@ suite("prompt", () => {
{ role: "assistant", content: "The capital of France is Paris." },
{ role: "user", content: "What about Spain?" },
],
model: "gpt-4",
model: "gpt-4o",
}),
})
.reply(
Expand Down Expand Up @@ -342,7 +342,7 @@ suite("prompt", () => {
},
{ role: "user", content: "Call the function" },
],
model: "gpt-4",
model: "gpt-4o",
toolsChoice: "auto",
}),
})
Expand Down Expand Up @@ -412,7 +412,7 @@ suite("prompt", () => {
content: "What is the capital of France?",
},
],
model: "gpt-4",
model: "gpt-4o",
}),
})
.reply(400, "Bad Request", {
Expand Down Expand Up @@ -453,7 +453,7 @@ suite("prompt", () => {
role: "user",
},
],
model: "gpt-4",
model: "gpt-4o",
toolsChoice: undefined,
},
},
Expand Down

0 comments on commit 2b49829

Please sign in to comment.