mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-15 13:14:35 +00:00
feat: models
This commit is contained in:
@@ -7,7 +7,11 @@ import type { OpenAICompatibleChatPrompt } from "./openai-compatible-api-types"
|
||||
import { convertToBase64 } from "@ai-sdk/provider-utils"
|
||||
|
||||
function getOpenAIMetadata(message: { providerOptions?: SharedV2ProviderMetadata }) {
|
||||
return message?.providerOptions?.copilot ?? {}
|
||||
const opts = message?.providerOptions ?? {}
|
||||
return {
|
||||
...(opts.openaiCompatible as Record<string, unknown> | undefined),
|
||||
...(opts.copilot as Record<string, unknown> | undefined),
|
||||
}
|
||||
}
|
||||
|
||||
export function convertToOpenAICompatibleChatMessages(prompt: LanguageModelV2Prompt): OpenAICompatibleChatPrompt {
|
||||
@@ -82,7 +86,6 @@ export function convertToOpenAICompatibleChatMessages(prompt: LanguageModelV2Pro
|
||||
|
||||
for (const part of content) {
|
||||
const partMetadata = getOpenAIMetadata(part)
|
||||
// Check for reasoningOpaque on any part (may be attached to text/tool-call)
|
||||
const partOpaque = (part.providerOptions as { copilot?: { reasoningOpaque?: string } })?.copilot
|
||||
?.reasoningOpaque
|
||||
if (partOpaque && !reasoningOpaque) {
|
||||
@@ -113,15 +116,25 @@ export function convertToOpenAICompatibleChatMessages(prompt: LanguageModelV2Pro
|
||||
}
|
||||
}
|
||||
|
||||
messages.push({
|
||||
const msg: any = {
|
||||
role: "assistant",
|
||||
content: text || undefined,
|
||||
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
|
||||
reasoning_text: reasoningOpaque ? reasoningText : undefined,
|
||||
reasoning_opaque: reasoningOpaque,
|
||||
reasoning_content: reasoningText,
|
||||
...metadata,
|
||||
})
|
||||
}
|
||||
|
||||
if (metadata?.reasoning_content) {
|
||||
msg.reasoning_content = metadata.reasoning_content
|
||||
} else if (reasoningText) {
|
||||
msg.reasoning_content = reasoningText
|
||||
}
|
||||
|
||||
if (reasoningOpaque) {
|
||||
msg.reasoning_opaque = reasoningOpaque
|
||||
if (reasoningText) msg.reasoning_text = reasoningText
|
||||
}
|
||||
|
||||
messages.push(msg)
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user