Skip to content
Open
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
2 changes: 1 addition & 1 deletion node-zerox/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const isGoogleCredentials = (
const isOpenAICredentials = (
credentials: any
): credentials is OpenAICredentials => {
return credentials && typeof credentials.apiKey === "string";
return credentials && typeof credentials.apiKey === "string" && credentials.baseUrl;
};

export const createModel = ({
Expand Down
4 changes: 3 additions & 1 deletion node-zerox/src/models/openAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import fs from "fs-extra";
export default class OpenAIModel implements ModelInterface {
private apiKey: string;
private model: string;
private baseUrl: string;
private llmParams?: Partial<OpenAILLMParams>;

constructor(
Expand All @@ -30,6 +31,7 @@ export default class OpenAIModel implements ModelInterface {
llmParams?: Partial<OpenAILLMParams>
) {
this.apiKey = credentials.apiKey;
this.baseUrl = credentials.baseUrl ?? 'https://api.openai.com/v1'
this.model = model;
this.llmParams = llmParams;
}
Expand Down Expand Up @@ -121,7 +123,7 @@ export default class OpenAIModel implements ModelInterface {

try {
const response = await axios.post(
"https://api.openai.com/v1/chat/completions",
`${this.baseUrl}/chat/completions`,
{
messages,
model: this.model,
Expand Down
1 change: 1 addition & 0 deletions node-zerox/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface GoogleCredentials {
}

export interface OpenAICredentials {
baseUrl: string;
apiKey: string;
}

Expand Down