mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
fix: handle undefined openai client in getModel
Co-Authored-By: Han Xiao <han.xiao@jina.ai>
This commit is contained in:
parent
fabea4de3b
commit
dc2c0cae5f
@ -55,13 +55,14 @@ export class LLMClient {
|
||||
if (llmConfig.provider === 'gemini') {
|
||||
return this.geminiClient.getGenerativeModel(options);
|
||||
} else if (this.openaiClient) {
|
||||
if (!this.openaiClient) {
|
||||
const client = this.openaiClient;
|
||||
if (!client) {
|
||||
throw new Error('OpenAI client not initialized. Set OPENAI_API_KEY and provider="openai" to use OpenAI.');
|
||||
}
|
||||
return {
|
||||
...this.openaiClient.chat.completions,
|
||||
...client.chat.completions,
|
||||
temperature: options.temperature,
|
||||
generateContent: (prompt: string) => this.generateContent(this.openaiClient.chat.completions, prompt)
|
||||
generateContent: (prompt: string) => this.generateContent(client.chat.completions, prompt)
|
||||
};
|
||||
}
|
||||
throw new Error('OpenAI client not initialized. Set OPENAI_API_KEY and provider="openai" to use OpenAI.');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user