Skip to content

Commit

Permalink
Merge pull request #14 from elie222/feat/openai-key-option
Browse files Browse the repository at this point in the history
feat: allow passing the openai api key as an option
  • Loading branch information
lucgagan authored Nov 17, 2023
2 parents 0e158c1 + 6a38a4c commit 086e9e8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const options = {
debug: boolean,
// The OpenAI model (https://platform.openai.com/docs/models/overview)
model: "gpt-4-1106-preview",
// The OpenAI API key
openaiApiKey: 'sk-...',
};
auto("<your prompt>", { page, test }, options);
Expand Down
1 change: 1 addition & 0 deletions src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async function runTask(
? {
model: options.model ?? "gpt-4-1106-preview",
debug: options.debug ?? false,
openaiApiKey: options.openaiApiKey,
}
: undefined,
});
Expand Down
2 changes: 1 addition & 1 deletion src/completeTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const completeTask = async (
page: Page,
task: TaskMessage
): Promise<TaskResult> => {
const openai = new OpenAI();
const openai = new OpenAI({ apiKey: task.options?.openaiApiKey });

let lastFunctionResult: null | { errorMessage: string } | { query: string } =
null;
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Test = TestType<any, any>;
export type StepOptions = {
debug?: boolean;
model?: string;
openaiApiKey?: string;
};

export type TaskMessage = {
Expand Down

0 comments on commit 086e9e8

Please sign in to comment.