mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
fix(cache): only inject prompt_cache_key for supported providers
Only inject prompt_cache_key for providers that support prompt caching (Claude, Anthropic, ZAI, Qwen, DeepSeek). This fixes issue #848 where NVIDIA API rejected the parameter.
This commit is contained in:
@@ -47,7 +47,10 @@ import {
|
||||
} from "@/lib/localDb";
|
||||
import { getExecutor } from "../executors/index.ts";
|
||||
import { getCacheControlSettings } from "@/lib/cacheControlSettings";
|
||||
import { shouldPreserveCacheControl } from "../utils/cacheControlPolicy.ts";
|
||||
import {
|
||||
shouldPreserveCacheControl,
|
||||
providerSupportsCaching,
|
||||
} from "../utils/cacheControlPolicy.ts";
|
||||
import { getCacheMetrics } from "@/lib/db/settings.ts";
|
||||
|
||||
import {
|
||||
@@ -955,9 +958,10 @@ export async function handleChatCore({
|
||||
? translatedBody
|
||||
: { ...translatedBody, model: modelToCall };
|
||||
|
||||
// Inject prompt_cache_key for OpenAI providers if not already set
|
||||
// Inject prompt_cache_key only for providers that support it
|
||||
if (
|
||||
targetFormat === FORMATS.OPENAI &&
|
||||
providerSupportsCaching(provider) &&
|
||||
!bodyToSend.prompt_cache_key &&
|
||||
Array.isArray(bodyToSend.messages)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user