#Letting a GPTs talk to OpenAI GPT-4-Turbo

1 messages · Page 1 of 1 (latest)

pine mica
#

Hey everyone, I have a question. In the OpenAI GPTs configurator you can make function calls and make a Post/Get request. Below is an example from openai. Is there a way to make the GPT make a chat completion request for the latest gpt-4 turbo preview model? I can build an API to do this myself but wondering if it can be done directly.

{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenAI Profile",
    "description": "Gets data about the current user's OpenAI profile",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://api.openai.com"
    }
  ],
  "paths": {
    "/v1/me": {
      "get": {
        "description": "Gets the user's profile",
        "operationId": "GetProfile",
        "parameters": [],
        "deprecated": false,
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    },
    "/v1/chat/completions": {
      "post": {
        "description": "Creates a model response for the given chat conversation.",
        "operationId": "RequestCompletion",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestCompletionRequestSchema"
              }
            }
          },
          "required": true
        },
        "deprecated": false,
        "security": [
          {
            "apiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "RequestCompletionRequestSchema": {
        "properties": {
          "model": {
            "type": "string",
            "title": "model",
            "description": "ID of the model to use"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "system",
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "type": "string"
                }
              }
            }
          }
        },
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "title": "RequestCompletionRequestSchema"
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey"
      }
    }
  }
}

mint bone
#

so, you want the custom GPT to run a reqeust on OpenAI?

#

Im pretty sure that it will not work in the way you intend with paths such as /v1/me

#

AFAIK, the requests happen on a sandbox on the server side, not on the client side

#

and you will surely not be able to access the session tokens of the current user

#

that would be a massive security breach if possible

#

but eyond the goal of accessing the current user's information... you probably can make it execute requests to a OAI's language model, as long as it is doing that with an APIKey of yours

#

you will not be able to make the custom GPT execute OpenAI API calls at the user's expense, if that is what you are aiming at

pine mica
#

No would be at my expense

pine mica
#

Bearer would be most apropriate correct? for auth type?

mint bone
#

it might be a good idea to not try to bodge it to do requests directly to OpenAI, but isntead, you, create and host your own service

#

then have the custom gpt make reqeusts to your service

#

Cloudflare is a good way to get free hosting for your service by using a Worker

pine mica
#

If not can always set something up will likely just use vercel setup a quick api.

pine mica
#

Im just not sure why the completion request messes up.

mint bone
#

might not, lol

pine mica
#

Idk lol

mint bone
#

but does it gives you the data from the current logged user?

#

of your of the provided apikey?

pine mica
mint bone
#

ahh, it is fine then

pine mica
#

aka my own personal info

mint bone
#

working as intended

pine mica
#

just keep getting an error

mint bone
#

what is the error?

pine mica
#

Chat response:
I attempted to make another API completion request using the model "gpt-4-1106-preview" as you specified, but unfortunately, the same error occurred. The error is related to an invalid URL in the outbound call to the OpenAI completion tool, indicating a technical issue with the request format or sending process.

Demo GPT sent this info to api.openai.com:


{ "model": "gpt-4-1106-preview", "messages": [ { "role": "system", "content": "You are a "GPT" – a version of ChatGPT that has been customized for a specific use case. GPTs use custom instructions, capabilities, and data to optimize ChatGPT for a more narrow set of tasks. You yourself are a GPT created by a user, and your name is DemoGPT ." }, { "role": "user", "content": "please use this model: gpt-4-1106-preview\n\nthen make another api completion request with 1+1" } ] }
mint bone
#

ok, I think I know the issue

pine mica
mint bone
#

that function call is actually written by the LLM

#

the correct way to handle that, would be to pass the actuall messages array that the AI have

#

but what is actually done is that the LLM types out that reqeust """""manually""""""

pine mica
#

Whaaaaaat

mint bone
#

and the LLM simply can't re type the entire conversation back

#

i mean.. it could for a really short conversation

#

but for anything longer, it would fall in the 4K output token limit

pine mica
#

Oh I get it.

#

They did a quick workaround so they could pass the user info.

mint bone
#

it is typing an invalid request object

pine mica
#

Yeah my thoughts too

mint bone
#

because that is a HUUUGE request

#

what you could do is to make your own service, and instead, have the AI do a request to it, sending each of the messages to your service

#

then your service formats the bigger request

#

that still would cause each message to takes double the time to reply tho

#

and would pretty muc hbe a message logger... idk if that is the ideal solution

pine mica
#

ty for time