Closed jackitaliano closed 2 months ago
Hey @jackitaliano.
Thankyou for letting me know about the issue. I apologise but I am unable to fully understand on how to re-produce the error. I have attempted to use the default Assistant Functions example and it appeared to work fine.
Could you let me know what code to use and what exactly to prompt so I can reproduce it on my computer.
Thankyou very much!!
Define assistant function as:
{
"name": "text_to_image",
"description": "Generate an image from a text description.",
"parameters": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "The description of the image to generate."
}
},
"required": []
}
}
Define function as:
async function genImage() {
await new Promise((resolve) => setTimeout(resolve, 500));
return "The image has been inserted into the chat."
}
Send message to assistant: "Generate an image of a military aircraft. First tell me the exact prompt, then generate the image. Then tell me about the image."
It seems to cause this error with any async function, so you could also do the example ones like "get_weather", just with a timeout. This is just the parts of one I had already.
Edit: In the Assistant Functions examples, that might be:
// using JavaScript for a simplified example
chatElementRef.directConnection = {
openAI: {
assistant: {
assistant_id: 'placeholder-id',
function_handler: (functionsDetails) => {
return functionsDetails.map(async (functionDetails) => this.getCurrentWeather(functionDetails.arguments));
},
},
key: 'placeholder-key',
},
};
async function getCurrentWeather(location) {
await new Promise((resolve) => setTimeout(resolve, 500));
location = location.toLowerCase();
if (location.includes('tokyo')) {
return 'Good';
} else if (location.includes('san francisco')) {
return 'Mild';
} else {
return 'Very Hot';
}
}
Hi @jackitaliano.
Thankyou for providing the info to reproduce the error. I am unfortunately going on a week long trip with limited access to the internet, hence I will unfortunately not be able to take care of the problem until I get back. My apologies. I will update this thread as soon as I am able to get progress on this.
Hi @jackitaliano.
Thankyou for providing the info to reproduce the error. I am unfortunately going on a week long trip with limited access to the internet, hence I will unfortunately not be able to take care of the problem until I get back. My apologies. I will update this thread as soon as I am able to get progress on this.
No worries, have a good trip!
Wanted to give you an update! I was able to fix the error for the default example, however I am still getting an error for genImage
. I will continue to investigate this tomorrow.
The fix has now been added to deep-chat-dev
and deep-chat-react-dev
package versions 9.0.183
. Let me know if this works for you. Thanks!
Hi, the fixes mentioned in this issue is now available in Deep Chat version 2.0.0
.
Scenario
deep-chat-dev
v9.0.179
directConnection
to OpenAI Assistants V2When the assistant first provides text, then makes an async function call, then provides text again (within the same run), I'm getting an error:
Recreate
Thoughts
I've tried debugging as much as I can, and as far as I can tell I've not done anything in the response interceptor to cause this. Our
responseInterceptor
is called, but does not change the object at all in this scenario.I've also stepped through
deep-chat
execution, and it seemsthis._elements
is undefined after an async tool call in finaliseStreamedMessage. Kind of curious because stepping through shows it as undefined, loggingthis
has a defined_elements
field, and loggingthis._elements
is undefined. Thinking this has something to do with why it only occurs on async calls that don't return immediately, which would affect the results based on timing?