mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 23:02:26 +00:00
fix: types
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import type { LanguageModelV2 } from "@ai-sdk/provider"
|
||||
import { type FetchFunction, withoutTrailingSlash, safeParseJSON, EventSourceParserStream } from "@ai-sdk/provider-utils"
|
||||
import {
|
||||
type FetchFunction,
|
||||
withoutTrailingSlash,
|
||||
safeParseJSON,
|
||||
EventSourceParserStream,
|
||||
} from "@ai-sdk/provider-utils"
|
||||
import { OpenAICompatibleChatLanguageModel } from "../copilot/chat/openai-compatible-chat-language-model"
|
||||
import { Log } from "@/util/log"
|
||||
|
||||
@@ -127,8 +132,8 @@ export function createToothFairyAI(options: ToothFairyAIProviderSettings = {}):
|
||||
return
|
||||
}
|
||||
|
||||
const parsed = await safeParseJSON({ text: data, schema: null })
|
||||
|
||||
const parsed = await safeParseJSON({ text: data })
|
||||
|
||||
if (!parsed.success) {
|
||||
log.error("Failed to parse SSE chunk", {
|
||||
chunk: data.slice(0, 100),
|
||||
@@ -138,7 +143,11 @@ export function createToothFairyAI(options: ToothFairyAIProviderSettings = {}):
|
||||
return
|
||||
}
|
||||
|
||||
const value = parsed.value
|
||||
const value = parsed.value as {
|
||||
status?: string
|
||||
choices?: Array<{ finish_reason?: string }>
|
||||
usage?: { prompt_tokens?: number; completion_tokens?: number; total_tokens?: number }
|
||||
}
|
||||
|
||||
if (value.status === "initialising" || value.status === "connected") {
|
||||
log.debug("filtered connection status", { status: value.status })
|
||||
|
||||
Reference in New Issue
Block a user