add kia ai chat tools 2
CI/CD Pipeline / build-and-deploy (push) Successful in 18s
Details
CI/CD Pipeline / build-and-deploy (push) Successful in 18s
Details
This commit is contained in:
parent
d450b318c0
commit
8301329aca
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
|
import asyncio
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
from datetime import date, datetime, timedelta, UTC
|
from datetime import date, datetime, timedelta, UTC
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|
@ -202,6 +203,13 @@ def chatbot_workflow(bot, now):
|
||||||
)
|
)
|
||||||
] + trimmed_messages
|
] + trimmed_messages
|
||||||
|
|
||||||
|
# KIA API returns choices=null in streaming chunks which breaks LangChain.
|
||||||
|
# Even with streaming=False, ainvoke() still uses _astream() internally in async path.
|
||||||
|
# asyncio.to_thread forces sync model.invoke() which calls the real non-streaming endpoint.
|
||||||
|
if is_kia:
|
||||||
|
print(f"[KiaAI] Calling model via asyncio.to_thread (non-streaming) | model='{bot.model}'")
|
||||||
|
response = await asyncio.to_thread(model.invoke, input_messages)
|
||||||
|
else:
|
||||||
response = await model.ainvoke(input=input_messages, **kwargs)
|
response = await model.ainvoke(input=input_messages, **kwargs)
|
||||||
|
|
||||||
if is_kia:
|
if is_kia:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue