add kia ai chat tools 1
CI/CD Pipeline / build-and-deploy (push) Successful in 20s
Details
CI/CD Pipeline / build-and-deploy (push) Successful in 20s
Details
This commit is contained in:
parent
1fbd29c1b0
commit
d450b318c0
|
|
@ -171,10 +171,11 @@ def audio_loader(content, query: str, audio: [str | None, str | None]):
|
|||
return content
|
||||
|
||||
def chatbot_workflow(bot, now):
|
||||
is_kia_model = bot.model.startswith("kia/")
|
||||
print(f"[chatbot_workflow] START | model='{bot.model}' | is_kia={is_kia_model} | web_search={bot.web_search}")
|
||||
|
||||
print(f"[get_model] Using model: {bot}")
|
||||
model = get_model(model=bot.model)
|
||||
print(f"[get_model] Using model: {model}")
|
||||
print(f"[chatbot_workflow] Model initialized: {type(model).__name__}")
|
||||
trimmer = get_trimmer()
|
||||
|
||||
if bot.web_search:
|
||||
|
|
@ -182,9 +183,13 @@ def chatbot_workflow(bot, now):
|
|||
|
||||
async def call_model(state: MessagesState):
|
||||
kwargs = {}
|
||||
if "gemini" not in bot.model:
|
||||
is_kia = bot.model.startswith("kia/")
|
||||
if "gemini" not in bot.model and not is_kia:
|
||||
kwargs["stream_usage"] = True
|
||||
|
||||
if is_kia:
|
||||
print(f"[KiaAI] call_model invoked | model='{bot.model}' | stream_usage disabled")
|
||||
|
||||
trimmed_messages = await trimmer.ainvoke(state["messages"])
|
||||
input_messages = [
|
||||
SystemMessage(
|
||||
|
|
@ -199,6 +204,13 @@ def chatbot_workflow(bot, now):
|
|||
|
||||
response = await model.ainvoke(input=input_messages, **kwargs)
|
||||
|
||||
if is_kia:
|
||||
print(f"[KiaAI] Response received | type={type(response).__name__}")
|
||||
print(f"[KiaAI] content='{response.content[:200] if response.content else None}'")
|
||||
print(f"[KiaAI] usage_metadata={response.usage_metadata}")
|
||||
print(f"[KiaAI] additional_kwargs={response.additional_kwargs}")
|
||||
print(f"[KiaAI] tool_calls={response.tool_calls}")
|
||||
|
||||
ai_msg_created_at = datetime.now(UTC).isoformat()
|
||||
response.additional_kwargs["created_at"] = ai_msg_created_at
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,17 @@ class KiaAIService:
|
|||
if reasoning_effort and model_name in REASONING_MODELS:
|
||||
model_kwargs["reasoning_effort"] = reasoning_effort
|
||||
|
||||
print(f"[KiaAI] Initializing model='{model_name}' | base_url='{base_url}' | reasoning_effort='{reasoning_effort}'")
|
||||
|
||||
# streaming=False is REQUIRED: KIA API returns chunks with choices=null
|
||||
# which causes TypeError in LangChain's _convert_chunk_to_generation_chunk.
|
||||
# Disabling streaming forces LangChain to use the non-streaming endpoint.
|
||||
return ChatOpenAI(
|
||||
model=model_name,
|
||||
api_key=settings.kia_api_key,
|
||||
base_url=base_url,
|
||||
model_kwargs=model_kwargs,
|
||||
streaming=False,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue