fix: missing providers that handle templating (#8438)

This commit is contained in:
Dallin Romney 2025-10-24 16:20:34 -07:00 • committed by GitHub
parent 20886604d8
commit 5e9ef89b7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 66 additions and 19 deletions

View file

@ -63,6 +63,47 @@ const PROVIDER_HANDLES_TEMPLATING: string[] = [
"watsonx",
"nebius",
"relace",
"openrouter",
"deepseek",
"xAI",
"groq",
"gemini",
"docker",
// TODO add these, change to inverted logic so only the ones that need templating are hardcoded
// Asksage.ts
// Azure.ts
// BedrockImport.ts
// Cerebras.ts
// Cloudflare.ts
// CometAPI.ts
// CustomLLM.ts
// DeepInfra.ts
// Fireworks.ts
// Flowise.ts
// FunctionNetwork.ts
// HuggingFaceInferenceAPI.ts
// HuggingFaceTEI.ts
// HuggingFaceTGI.ts
// Inception.ts
// Kindo.ts
// LlamaCpp.ts
// LlamaStack.ts
// Llamafile.ts
// Mock.ts
// Moonshot.ts
// NCompass.ts
// OVHcloud.ts
// Replicate.ts
// Scaleway.ts
// SiliconFlow.ts
// TARS.ts
// Test.ts
// TextGenWebUI.ts
// TransformersJsEmbeddingsProvider.ts
// Venice.ts
// Vllm.ts
// Voyage.ts
// etc
];
const PROVIDER_SUPPORTS_IMAGES: string[] = [

View file

@ -1164,7 +1164,20 @@ export abstract class BaseLLM implements ILLM {
let citations: null | string[] = null;
try {
{
if (this.templateMessages) {
for await (const chunk of this._streamComplete(
prompt,
signal,
completionOptions,
)) {
completion.push(chunk);
interaction?.logItem({
kind: "chunk",
chunk: chunk,
});
yield { role: "assistant", content: chunk };
}
} else {
if (this.shouldUseOpenAIAdapter("streamChat") && this.openaiAdapter) {
let body = toChatBody(messages, completionOptions, {
includeReasoningField: this.supportsReasoningField,

View file

@ -9,37 +9,32 @@ import {
CompletionCreateParams,
} from "openai/resources/index";
import type {
EasyInputMessage,
Response as OpenAIResponse,
ResponseStreamEvent,
ResponseTextDeltaEvent,
ResponseTextDoneEvent,
ResponseReasoningSummaryTextDeltaEvent,
ResponseReasoningSummaryTextDoneEvent,
ResponseReasoningTextDeltaEvent,
ResponseReasoningTextDoneEvent,
ResponseFunctionToolCall,
ResponseInput,
ResponseInputItem,
ResponseInputMessageContentList,
ResponseOutputMessage,
ResponseOutputText,
ResponseFunctionToolCall,
EasyInputMessage,
ResponseReasoningItem,
ResponseReasoningSummaryTextDeltaEvent,
ResponseReasoningSummaryTextDoneEvent,
ResponseReasoningTextDeltaEvent,
ResponseReasoningTextDoneEvent,
ResponseStreamEvent,
ResponseTextDeltaEvent,
} from "openai/resources/responses/responses.mjs";
import {
AssistantChatMessage,
ChatMessage,
CompletionOptions,
MessageContent,
MessagePart,
TextMessagePart,
ThinkingChatMessage,
ToolCallDelta,
AssistantChatMessage,
UserChatMessage,
SystemChatMessage,
ToolResultChatMessage,
MessageContent,
ImageMessagePart,
MessagePart,
} from "..";
function appendReasoningFieldsIfSupported(
@ -329,8 +324,6 @@ export function fromChatResponse(response: ChatCompletion): ChatMessage[] {
export function fromChatCompletionChunk(
chunk: ChatCompletionChunk,
): ChatMessage | undefined {
console.log("chunk", chunk);
const delta = chunk.choices?.[0]?.delta as
| (ChatCompletionChunk.Choice.Delta & {
reasoning?: string;