Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use gpt-4o as default model #63

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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