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: Avoid baseURL being an empty string, resulting in incorrect cl… #3308

Merged
merged 1 commit into from
Jul 26, 2024
Merged
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
6 changes: 4 additions & 2 deletions src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts
Original file line number Diff line number Diff line change
@@ -128,8 +128,10 @@ export const LobeOpenAICompatibleFactory = <T extends Record<string, any> = any>
private _options: ConstructorOptions<T>;

constructor(options: ClientOptions & Record<string, any> = {}) {
const { apiKey, baseURL = DEFAULT_BASE_URL, ...res } = options;
this._options = options as ConstructorOptions<T>;
const _options = { ...options, baseURL: options.baseURL?.trim() || DEFAULT_BASE_URL };
const { apiKey, baseURL = DEFAULT_BASE_URL, ...res } = _options;
this._options = _options as ConstructorOptions<T>;

if (!apiKey) throw AgentRuntimeError.createError(ErrorType?.invalidAPIKey);

this.client = new OpenAI({ apiKey, baseURL, ...constructorOptions, ...res });
4 changes: 4 additions & 0 deletions src/services/chat.ts
Original file line number Diff line number Diff line change
@@ -125,6 +125,10 @@ export function initializeWithClientStore(provider: string, payload: any) {
break;
}
case ModelProvider.Perplexity: {
providerOptions = {
apikey: providerAuthPayload?.apiKey,
baseURL: providerAuthPayload?.endpoint,
};
break;
}
case ModelProvider.Qwen: {