#Custom Data-Fetch Function Calling based on User Prompt

1 messages · Page 1 of 1 (latest)

signal prairie
#

will custom-GPT built on chatGPT from OpenAI, accept a function, which allows custom-GPT to call external api for data sets that it thinks is needed to answer a user's prompt.

Sample function:
Function name: customDataFetch
Description: "while calling this function, you can retrieve any of below mentioned attributes for an external api.
Sample attributes:
getCompanyName
getCeoName
getYearCreated"

Custom-GPT payload sample could like this this.

Function: customDataFetch
{
getCompanyName : ""
getYearCreated:""
}

tropic kestrelBOT
#

Hi @signal prairie. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, OpenAI's custom GPT models built on ChatGPT can be designed to call external APIs for fetching data sets that it deems necessary to answer a user's prompt. This is achieved through the use of function calling, which allows the model to interact with defined functions that can call external APIs.

Here's a basic sequence of steps for function calling:

  1. Call the model with the user query and a set of functions defined in the functions parameter.
  2. The model can choose to call one or more functions; if so, the content will be a stringified JSON object adhering to your custom schema.
  3. Parse the string into JSON in your code, and call your function with the provided arguments if they exist.
  4. Call the model again by appending the function response as a new message, and let the model summarize the results back to the user.

In your case, you can define a function like customDataFetch that can retrieve attributes like getCompanyName, getCeoName, and getYearCreated from an external API. The model can then convert a user's natural language prompt into a call to this function, fetch the required data, and use it to generate a response.

However, please note that the model may hallucinate parameters, and you need to handle such cases in your code.

For more details, you can refer to the OpenAI Function Calling Guide (https://platform.openai.com/docs/guides/function-calling).

Please note that the actual implementation of the function and the handling of the API calls would depend on the specific requirements of your application and the API you are interacting with.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@signal prairie kapa.ai is still learning and improving, please let us know how it did by reacting below

signal prairie
#

@tropic kestrel can dataWriteToExternal app function be called by cutom-GPT. Buy calling these finctions user custom-GPT user can send data to external app.
Can custom-GPT include user_unique_persistent_id in the request payload?

tropic kestrelBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Yes, OpenAI's custom GPT models can be designed to call functions that send data to external applications. You can define a function like dataWriteToExternal that sends data to an external app based on the user's input or the model's decision.

However, including a user_unique_persistent_id in the request payload would depend on how you implement the function and handle the API calls. It's important to ensure that any user data is handled securely and in compliance with privacy regulations.

OpenAI recommends sending end-user IDs in your requests as a useful tool to help monitor and detect abuse. This allows OpenAI to provide your team with more actionable feedback in the event that they detect any policy violations in your application. The IDs should be a string that uniquely identifies each user. OpenAI recommends hashing their username or email address, in order to avoid sending any identifying information. If you offer a preview of your product to non-logged in users, you can send a session ID instead. You can include end-user IDs in your API requests via the user parameter as follows:

from openai import OpenAI
client = OpenAI()

response = client.completions.create(
 model="gpt-3.5-turbo-instruct",
 prompt="This is a test",
 max_tokens=5,
 user="user_123456"
)

(Source: OpenAI Safety Best Practices (https://platform.openai.com/docs/guides/safety-best-practices))

Please note that the actual implementation of the function and the handling of the API calls would depend on the specific requirements of your application and the API you are interacting with.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: