https://discord.gg/botpress logo
#🤝help
Autosummarizing Conversations in Botpress Agent
# 🤝help
s

stocky-sunset-29150

02/17/2024, 8:54 AM
I have an issue with Botpress autosummarizing all the chats I have with the bot. How do I disable it?
j

jolly-policeman-82775

02/17/2024, 9:20 AM
you can disable the summary agent here
s

stocky-sunset-29150

02/17/2024, 9:54 AM
@jolly-policeman-82775 Still have the same issue
j

jolly-policeman-82775

02/17/2024, 9:54 AM
hm
So the text is not completing ?
or what is the problem ?
@stocky-sunset-29150
ohhh
hm, could you share your chatbot with me ?
s

stocky-sunset-29150

02/17/2024, 11:49 AM
I just checked, its not the summary bot. Its in the code. If the openAI API status is successful, it gets the POST result. But if it fails, it repeats the message. This issue happens when the OpenAI API retrieval fails, so I need a way to mitigate the issue, either to resend the text, retry again or create a new thread
@jolly-policeman-82775
j

jolly-policeman-82775

02/17/2024, 11:57 AM
hi
uumm
idk
@fresh-fireman-491
when your free
gl
f

fresh-fireman-491

02/17/2024, 12:06 PM
I don't think I haven't played around with the OpenAI assistants enough to solve this unfortunately, but I can try. What variable are you sending that is repeating the users question
And can you share the code that sets that variable.
s

stocky-sunset-29150

02/17/2024, 12:25 PM
workflow.required_action = {} const creationResponse = await bot.retryingAxiosRequest({ method: 'post', maxBodyLength: Infinity, url:
https://api.openai.com/v1/threads/${workflow.threadId}/runs
, headers: { 'OpenAI-Beta': 'assistants=v1', Authorization:
Bearer ${env.openAIToken}
, 'Content-Type': 'application/json' }, data: JSON.stringify({ assistant_id: env.assistantId }) }) const runId = creationResponse.data.id workflow.runId = runId const waitTillRunComplete = async () => { const statusResponse = await bot.retryingAxiosRequest({ method: 'get', maxBodyLength: Infinity, url:
https://api.openai.com/v1/threads/${workflow.threadId}/runs/${runId}
, headers: { 'OpenAI-Beta': 'assistants=v1', Authorization:
Bearer ${env.openAIToken}
, 'Content-Type': 'application/json' } }) if (['queued', 'in_progress'].includes(statusResponse.data.status) === false) { console.log('the status is:', statusResponse.data.status) if (statusResponse.data.status === 'requires_action') { workflow.required_action = statusResponse.data.required_action } return } await new Promise((resolve) => { setTimeout(resolve, 1000) }) await waitTillRunComplete() } await waitTillRunComplete()
This code snippet is designed to interact with an OpenAI API, specifically for creating and managing "runs" within a workflow. Here's a step-by-step explanation of what it does: Initialize an Empty Required Action Object: It starts by initializing workflow.required_action as an empty object. This is presumably meant to hold any actions required after a run is initiated, based on the response from the API. Create a New Run: It sends a POST request to the OpenAI API to create a new run associated with a specific thread ID (workflow.threadId). The request includes: An assistant_id in the request body, taken from env.assistantId, which identifies the specific assistant to use for the run. Necessary headers for authentication (Authorization) and to specify the request format (Content-Type: application/json). Store Run ID: After creating the run, it stores the run's ID (creationResponse.data.id) both in a local variable runId and in workflow.runId for later use. Define a Function to Check Run Status: waitTillRunComplete is an asynchronous function defined to repeatedly check the status of the initiated run by sending a GET request to the OpenAI API. It uses the stored runId to construct the request URL.
Check Run Status: The function checks the run's status in the response. If the status is not queued or in_progress, it logs the status and performs additional checks: If the status is requires_action, it updates workflow.required_action with the required action from the response. This indicates that some additional steps are needed from the user or the system for the run to proceed or complete. If the run is still queued or in_progress, it waits for 1 second (using setTimeout) before checking the status again. This is a recursive call to waitTillRunComplete, creating a loop that continues until the run completes or requires an action. Execute Status Check: Finally, it calls waitTillRunComplete to start the process of monitoring the run's status until it is complete or requires action. In summary, this code initiates a run with the OpenAI API, then enters a monitoring phase where it checks the status of the run at 1-second intervals. If the run requires an action or completes, it exits the monitoring phase, with any required actions made available in workflow.required_action. This pattern of polling is common in asynchronous API interactions, where the completion time of a request (a "run" in this case) is uncertain.
From what ChatGPT has mentioned
f

fresh-fireman-491

02/17/2024, 1:28 PM
Can you send me the code that saves the response from the assistant
s

stocky-sunset-29150

02/17/2024, 10:44 PM