Skip to content

Commit

Permalink
chore: remove t.optional and add baseUrl check
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Sep 26, 2024
1 parent 5076ec8 commit d8bd296
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/handlers/ask-gpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export async function askGpt(context: Context, formattedChat: string) {
config: { model, openAiBaseUrl },
} = context;

const openAi = new OpenAI({ apiKey: OPENAI_API_KEY, baseURL: openAiBaseUrl });
const openAi = new OpenAI({
apiKey: OPENAI_API_KEY,
...(openAiBaseUrl && { baseUrl: openAiBaseUrl }),
});

const chat = createChatHistory(formattedChat);

Expand Down
4 changes: 2 additions & 2 deletions src/types/plugin-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface PluginInputs<T extends SupportedEventsU = SupportedEventsU, TU
*/

export const pluginSettingsSchema = T.Object({
model: T.Optional(T.String({ default: "o1-mini" })),
openAiBaseUrl: T.Optional(T.String({ default: "" })),
model: T.String({ default: "o1-mini" }),
openAiBaseUrl: T.String({ default: "" }),
});

export const pluginSettingsValidator = new StandardValidator(pluginSettingsSchema);
Expand Down

0 comments on commit d8bd296

Please sign in to comment.