How to Define a Function While Creating an Assistant Using OpenAI Assistants API?

This topic was automatically generated from Slack. You can find the original thread here.

Hi everyone !
I am trying to use the openAI assistants api. It works fine with the built in tools. But how can we define a function while creating an assistant?

But how can we define a function while creating an assistant?
I’m not sure what you mean here

OpenAI allows you to define custom functions and those functions can be passed to the assistant so that it can decide if they need to be used.
https://platform.openai.com/docs/assistants/tools

Currently pipedream is only allowing to select one of the existing tools and I am not sure how I can define a function. Screenshot attached for reference.

can you help with that ?

Thanks for reporting this , I can see that Pipedream currently not supporting function. I’ve created a ticket here and add to Pipedream backlog: [FEATURE] Open AI - Create Assistant: Support function in `Tools` prop · Issue #8974 · PipedreamHQ/pipedream · GitHub

Pipedream component dev will take a look soon!

Hi ,

Technically we do support the tools parameter within Python & Node.js code steps, so you can define function_calls when you’re creating an Assistant.

We actually just did a live demo showing how to use the newest OpenAI integrations on Pipedream, which you can watch here: https://www.youtube.com/watch?v=c4F0I-gjZTQ&lc=Ugww6DbrZqV42tq6gtp4AaABAg

The issue with OpenAI’s Assistant API at the moment is that Runs do not currently notify of state changes over webhooks. You’ll have to poll runs to check if they require function calling fulfillment.

We cover this in the live demo, but this is beyond a Pipedream limitation, it’s within the API itself. You’ll probably run into rate limit issues.

Here’s a demo workflow you can copy that leverages function_calls within an OpenAI Assistant, then leverages $.flow.rerun to poll the API for state changes: