Fixed model mismatch

This commit is contained in:
Pugazhendhi
2025-01-23 10:33:39 +05:30
committed by Vignesh Subbiah
parent 62dcfbe549
commit 02ccd77004

View File

@@ -4,26 +4,22 @@ import { Anthropic } from "@anthropic-ai/sdk"
import { ApiHandler } from "../index" import { ApiHandler } from "../index"
export class UnboundHandler implements ApiHandler { export class UnboundHandler implements ApiHandler {
private unboundApiKey: string
private unboundModelId: string
private unboundBaseUrl: string = "https://ai-gateway-43843357113.us-west1.run.app/v1" private unboundBaseUrl: string = "https://ai-gateway-43843357113.us-west1.run.app/v1"
private options: ApiHandlerOptions private options: ApiHandlerOptions
constructor(options: ApiHandlerOptions) { constructor(options: ApiHandlerOptions) {
this.options = options this.options = options
this.unboundApiKey = options.unboundApiKey || ""
this.unboundModelId = options.unboundModelId || ""
} }
async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream { async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
const response = await fetch(`${this.unboundBaseUrl}/chat/completions`, { const response = await fetch(`${this.unboundBaseUrl}/chat/completions`, {
method: "POST", method: "POST",
headers: { headers: {
Authorization: `Bearer ${this.unboundApiKey}`, Authorization: `Bearer ${this.options.unboundApiKey}`,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify({ body: JSON.stringify({
model: this.unboundModelId, model: this.getModel().id,
messages: [{ role: "system", content: systemPrompt }, ...messages], messages: [{ role: "system", content: systemPrompt }, ...messages],
}), }),
}) })