Replies: 2 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I've made a few changes to output parsing, and everything seems to be working, can you tell me if I did everything right? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Remi,
I'm integrating the Google Gemini streaming API (
streamGenerateContent?alt=sse) and have encountered a specific behavior I'm not sure how to handle correctly within LHC.The Problem:
The integration works perfectly for simple text responses. However, when Gemini uses its native
file_searchtool, the bot fails to display the final answer.Through
cURLdebugging, I've discovered that whenfile_searchis used, the Gemini stream response is structured as follows:functionCallevent (e.g.,{"functionCall": {"name": "google:file_search", ...}}).{"text": "You can download..."}).The issue seems to be that LHC correctly identifies the initial
functionCallevent but then appears to stop processing the stream. It doesn't read the subsequent text parts that arrive right after, so the user never sees the final message.My Core Question:
My request
bodyandtoolsconfiguration seem correct, as Gemini does attempt to use the tool. The issue appears to be in parsing this specific stream structure.What is the recommended way to configure LHC to correctly handle a single stream that begins with a
functionCallevent and is immediately followed by the text content of the message? Is this a known behavior that requires a specific setup in the REST API output definitions or Bot Triggers?I'm trying to understand if I'm missing a configuration step or if the stream parser isn't expecting this sequence of events from an API.
For your reference, I've attached my REST API and Bot configurations, plus the full
cURLlog that clearly shows thefunctionCallevent followed by the text events in the same stream.Thank you for your expertise and guidance.
Here is the JSON
bodyI am using for the REST API call:{ "system_instruction": { "parts": [ { "text": "Ты — Смарти, AI-ассистент техподдержки. Твоя задача — отвечать на вопросы, используя поиск по базе знаний, или вызывать функции, если этого требует ситуация.\n\n- Для ответов на вопросы по продуктам, ошибкам и инструкциям используй поиск по базе знаний (`file_search`).\n- Если пользователь прямо просит связать с оператором, купить что-то или активировать устройство, используй функции `call_operator`, `call_sales` или `activate_device`.\n- Если после двух неудачных поисков в базе знаний ты не нашел ответ, молча вызови `call_operator`.\n- Если запрос пользователя неясен или это приветствие, просто ответь текстом." } ] }, "contents": [ {if_previous_visitor_messages_list} {previous_visitor_messages_list_url__30__0} {skip_empty_msg} {separator},{/separator} { "role": "{assistant}model{/assistant}{user}user{/user}", "parts": [{ "text": {not_item_empty__args.item.msg}{{args.item.msg}}{/not_item_empty} }] } {/previous_visitor_messages_list_url} {/if_previous_visitor_messages_list} ], "generationConfig": { "maxOutputTokens": 3000, "temperature": 0.5 }, "tools": [ { "functionDeclarations": [ { "name": "call_operator", "description": "Вызвать, если пользователь просит оператора ИЛИ после двух неудачных поисков." }, { "name": "activate_device", "description": "Вызвать при прямом требовании пользователя НАЧАТЬ активацию." }, { "name": "call_sales", "description": "Вызвать, если пользователь явно хочет купить/продлить подписку." } ] }, { "file_search": { "file_search_store_names": [ "fileSearchStores/smartdiag-knowledge-base-ct077nqm6qu6" ] } } ] }I have attached my exported Bot and REST API configurations, along with a detailed
cURLlog showing the full stream response from Gemini for the failing request. The log clearly shows thefunctionCallevent followed by the text content events that are currently being ignored.Thank you for your guidance on how to configure LHC to handle this specific streaming behavior.
rest-api-55.json
lhc-bot-83.json
Click to view the full cURL log for the failing request
curl -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:streamGenerateContent?alt=sse&key=AIzaSyBsnjd3WLrG8zQ8c-kCJNthA2lj9LKzMhM' \ -H 'Content-Type: a...' --data-binary @- << 'CURL_DATA_EOF' { "system_instruction": { "parts": [ { "text": "\u0422\u044b \u2014 \u0421\u043c\u0430\u0440\u0442\u0438, AI-\u0430\u0441\u0441\u0438\u0441\u0442\u0435\u043d\u0442 \u0442\u0435\u0445\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438. \u0422\u0432\u043e\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0431\u0430\u0437\u0435 \u0437\u043d\u0430\u043d\u0438\u0439, \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f.\n\n- \u0414\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u043c, \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0431\u0430\u0437\u0435 \u0437\u043d\u0430\u043d\u0438\u0439 (`file_search`).\n- \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u044f\u043c\u043e \u043f\u0440\u043e\u0441\u0438\u0442 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0441 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c, \u043a\u0443\u043f\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 `call_operator`, `call_sales` \u0438\u043b\u0438 `activate_device`.\n- \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u0432 \u0431\u0430\u0437\u0435 \u0437\u043d\u0430\u043d\u0438\u0439 \u0442\u044b \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u043e\u0442\u0432\u0435\u0442, \u043c\u043e\u043b\u0447\u0430 \u0432\u044b\u0437\u043e\u0432\u0438 `call_operator`.\n- \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435\u044f\u0441\u0435\u043d \u0438\u043b\u0438 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u043c." } ] }, "contents": [ { "role": "user", "parts": [ { "text": "\u0439\u043e" } ] }, { "role": "model", "parts": [ { "text": "\u041f\u0440\u0438\u0432\u0435\u0442! \u0427\u0435\u043c \u043c\u043e\u0433\u0443 \u043f\u043e\u043c\u043e\u0447\u044c?" } ] }, { "role": "user", "parts": [ { "text": "\u0433\u0434\u0435 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0430\u0441\u044e?" } ] }, { "role": "model", "parts": [ { "text": "\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 **\"\u0412\u0430\u0441\u044f\"** (\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u043a\u0430\u043a VCDS) \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435.\n\n\u0412\u043e\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f:\n\n1. \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u043d\u0430\u0448 **\u0441\u0430\u0439\u0442**.\n2. \u0412 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043c\u0435\u043d\u044e \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b **\"\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\"**.\n3. \u0412 \u0441\u043f\u0438\u0441\u043a\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 **\"\u041c\u0430\u0440\u043e\u0447\u043d\u044b\u0435\"**.\n4. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 **\"VCDS\/\u0412\u0430\u0441\u044f\"** \u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 **\"\u0421\u043a\u0430\u0447\u0430\u0442\u044c\"** .\n\n**\u0412\u0430\u0436\u043d\u043e:** \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \"\u0412\u0430\u0441\u044f\" \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b **Windows**. \u0412\u0435\u0440\u0441\u0438\u0439 \u0434\u043b\u044f Android \u0438\u043b\u0438 iPhone \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 .\n\n\u0422\u0430\u043a\u0436\u0435 **\u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c** \u043f\u0435\u0440\u0435\u0434 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441 \u0438 \u0431\u0440\u0430\u043d\u0434\u043c\u0430\u0443\u044d\u0440, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u043b\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 ." } ] }, { "role": "user", "parts": [ { "text": "\u0430 \u0430\u0432\u043a\u0442\u043e\u043e\u043c?" } ] } ], "generationConfig": { "maxOutputTokens": 3000, "temperature": 0.5 }, "tools": [ { "functionDeclarations": [ { "name": "call_operator", "description": "\u0412\u044b\u0437\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0418\u041b\u0418 \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432." }, { "name": "activate_device", "description": "\u0412\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u0440\u044f\u043c\u043e\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u041d\u0410\u0427\u0410\u0422\u042c \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044e." }, { "name": "call_sales", "description": "\u0412\u044b\u0437\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u044f\u0432\u043d\u043e \u0445\u043e\u0447\u0435\u0442 \u043a\u0443\u043f\u0438\u0442\u044c\/\u043f\u0440\u043e\u0434\u043b\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443." } ] }, { "file_search": { "file_search_store_names": [ "fileSearchStores\/smartdiag-knowledge-base-ct077nqm6qu6" ] } } ] } CURL_DATA_EOFBeta Was this translation helpful? Give feedback.
All reactions