Skip to content

Commit aae647e

Browse files
committed
Fix options passed to super
1 parent 3258b15 commit aae647e

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/api/providers/base-openai-compatible-provider.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,35 @@ export abstract class BaseOpenAiCompatibleProvider<ModelName extends string>
4949

5050
this.options = options
5151

52+
if (!this.options.apiKey) {
53+
throw new Error("API key is required")
54+
}
55+
5256
this.client = new OpenAI({
5357
baseURL,
54-
apiKey: this.options.apiKey ?? "not-provided",
58+
apiKey: this.options.apiKey,
5559
defaultHeaders: DEFAULT_HEADERS,
5660
})
5761
}
5862

5963
override async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
60-
const { id: modelId, info: modelInfo } = this.getModel()
64+
const {
65+
id: model,
66+
info: { maxTokens: max_tokens },
67+
} = this.getModel()
68+
69+
const temperature = this.options.modelTemperature ?? this.defaultTemperature
6170

62-
const stream = await this.client.chat.completions.create({
63-
model: modelId,
64-
max_tokens: modelInfo.maxTokens,
65-
temperature: this.options.modelTemperature ?? this.defaultTemperature,
71+
const params: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = {
72+
model,
73+
max_tokens,
74+
temperature,
6675
messages: [{ role: "system", content: systemPrompt }, ...convertToOpenAiMessages(messages)],
6776
stream: true,
6877
stream_options: { include_usage: true },
69-
})
78+
}
79+
80+
const stream = await this.client.chat.completions.create(params)
7081

7182
for await (const chunk of stream) {
7283
const delta = chunk.choices[0]?.delta

src/api/providers/chutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { BaseOpenAiCompatibleProvider } from "./base-openai-compatible-provider"
55
export class ChutesHandler extends BaseOpenAiCompatibleProvider<ChutesModelId> {
66
constructor(options: ApiHandlerOptions) {
77
super({
8+
...options,
89
providerName: "Chutes",
910
baseURL: "https://llm.chutes.ai/v1",
1011
apiKey: options.chutesApiKey,
1112
defaultProviderModelId: chutesDefaultModelId,
1213
providerModels: chutesModels,
1314
defaultTemperature: 0.5,
14-
...options,
1515
})
1616
}
1717
}

src/api/providers/groq.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { BaseOpenAiCompatibleProvider } from "./base-openai-compatible-provider"
55
export class GroqHandler extends BaseOpenAiCompatibleProvider<GroqModelId> {
66
constructor(options: ApiHandlerOptions) {
77
super({
8+
...options,
89
providerName: "Groq",
910
baseURL: "https://api.groq.com/openai/v1",
1011
apiKey: options.groqApiKey,
1112
defaultProviderModelId: groqDefaultModelId,
1213
providerModels: groqModels,
1314
defaultTemperature: 0.5,
14-
...options,
1515
})
1616
}
1717
}

0 commit comments

Comments
 (0)