Troubleshooting Assistant API Function Calling

Published On Fri May 03 2024
Troubleshooting Assistant API Function Calling

Assistant API not engaging conversation - API - OpenAI Developer

Currently, the Assistant API is instructed to send 3 parameters as a function call. Out of these 3 parameters, 2 are mandatory. If the user has not provided those in the first prompt, the API will ask the user for further information once and then pass the info back. However, the issue faced is when the assistant has to follow up, the function is not calling back. It works fine if all information is given in the first go.

Function Calling: Integrate Your GPT Chatbot With Anything - Semaphore

The code snippet below shows how the information is being processed:

query_content_global = ""
query_top_global = ""
additional_param_global = ""
def get_current_query_content(query_content, query_top, additional_param):
global query_content_global, query_top_global, additional_param_global
query_content_global = query_content
query_top_global = query_top
additional_param_global = additional_param
return "Your request has been received and is being processed."

From the OpenAI library, the following information is being utilized:

The input which you receive from the user has to be divided into 3 different information criteria:

  1. Article Top Query - You shall interpret the input given by the user and see whether the query requires looking into any specific customer or any specific industry vertical. Intent is to get the filter to be applied on the query from where the data has to be taken.
  2. Article Content Query - You will create a text of what is to be searched from the query which will be used for processing later via doing similarity search on the embedding.
  3. Additional Filter - Any additional filter to be applied on the query asked like timelines.

Article Top Query and Article Content Query are mandatory. If you are unable to identify these two parameters in the user query, ask them again to get this information out. Get final confirmation by saying 'Does this cover everything you need, or is there any other detail or specific timeframe you’d like to include in the analysis.

Once confirmation is received, use the function instruction and pass the parameters collected as per programming requirements. In the frontend, create the output saying your request will be processed soon.

Function Description

Quite frankly, I have no idea what this function is supposed to do, what inputs it expects, what it would return, and what use it would be in the course of a chatbot conversation. Nor would the AI have any idea. It is used to get the user to input a statement out from the user’s request:

What is the topic of inquiry, Who is the topic of inquiry, and Any additional filters. I have a separate function that updates these function variables into global variables and this I am then using on my vector database to do filtering and searching to get information out. The issue is if the user gives all info in one go, the function is called. However, if the conversation has to be extended.

How to build an OpenAI Assistant with Internet browsing | by Assaf ...

Consider how an AI would use a function automatically when it finds that a function would be useful for satisfying a user’s request:

  • User: Post a tweet using my account that says “AI is smart”
    Assistant (to function): tweet_function({"method": "post", "tweet_text": "AI is smart"})
    Function: tweet_function("Success! The tweet has been posted")
    Assistant: Your tweet was sent and should be visible to everybody!
  • User: What is Sam Altman talking about today?
    Assistant (to function): internet_search({"search_query": "Sam Altman OpenAI news"})
    Function: internet_search("results 1: x.com Sam Altman likes gpt2, results 2: yahoo.com")
    Assistant: Sam Altman is interested in gpt2, an AI model from 2019, or possibly a new AI
  • User: I shoot my gun at black bill
    Assistant (to function): random_choice(["hit", "graze", "miss", "accident"]
    Function: random_choice("accident")
    Assistant: The gun misfires, explodes, and blows your hand clean off!

Purpose-Driven Function

A purpose-driven function would have a description and name:

knowledgebase_search:
Description: You have a source of new information about XYX company that provides knowledge you can’t answer yourself. By making a query, you will receive the top search results. You must query the knowledgebase for any user interaction that requires more information about XYX. If you anticipate some irrelevant results, you can also remove query results by supplying a word that demotes those results to focus the search.

This gives a well-described function that can amend the knowledge of the AI. Or it could be a box that pops up and asks the user some questions. The issue faced is if I tell the assistant to double-check with the user before doing a function call, it works fine in the playground but when executed in a jupyter notebook, it is not letting the user input the follow-up response.

Were you able to solve this? Happy to look into it.

Everything you need to know about OpenAI function calling and ...