mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-11-01 13:25:18 +08:00
Strip provider metadata at the Groq request boundary
Co-authored-by: multica-agent <[email protected]>
This commit is contained in:
co-authored by
multica-agent
parent
e212f9ead1
commit
fefe4d8552
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import typing
|
||||
import asyncio
|
||||
import copy
|
||||
|
||||
import litellm
|
||||
from litellm import acompletion, aembedding, arerank
|
||||
@@ -1121,6 +1122,17 @@ class LiteLLMRequester(requester.ProviderAPIRequester):
|
||||
# and imports proxy-only dependencies such as FastAPI.
|
||||
args['_skip_mcp_handler'] = True
|
||||
|
||||
destination_provider = args.get('custom_llm_provider') or str(args['model']).partition('/')[0]
|
||||
if destination_provider == 'groq':
|
||||
# Internal history metadata is not part of Groq's message schema.
|
||||
# Copy at the request boundary so fallback providers can still
|
||||
# replay signatures from the same conversation/tool-call history.
|
||||
args['messages'] = copy.deepcopy(args['messages'])
|
||||
for message in args['messages']:
|
||||
message.pop('provider_specific_fields', None)
|
||||
for tool_call in message.get('tool_calls') or []:
|
||||
tool_call.pop('provider_specific_fields', None)
|
||||
|
||||
return args
|
||||
|
||||
async def count_tokens(
|
||||
|
||||
Reference in New Issue
Block a user