Skip to content

WARNING: Failed to retrieve data from OpenAI. Response code is 400 #3

@lowlune

Description

@lowlune

Function

Public Function GPT(ByVal strPrompt) As String
    
    'Purpose: This function is an example of how to create a UDF using the OpenAI API
    '         so that it can be called directly on a worksheet in Excel
    
    Dim oOpenAI As clsOpenAI
    Dim oMessages As New clsOpenAIMessages
    Dim oResponse As clsOpenAIResponse
    
    GPT = Empty
    
    Set oOpenAI = New clsOpenAI
    
    oOpenAI.API_KEY = API_KEY
    
    oMessages.AddUserMessage strPrompt

    Set oResponse = oOpenAI.ChatCompletion(oMessages)
    If Not oResponse Is Nothing Then
        GPT = oResponse.MessageContent
    End If
    
    Set oResponse = Nothing
    Set oOpenAI = Nothing
    Set oMessages = Nothing
End Function

Cell prompt

=GPT("As a marketing expert, your job is to figure out who would probably be most interested in a specific product or service, based on a short description. Please give a brief answer that includes the most likely characteristics of the customers. This should i"&"nclude things like their age, gender, how much money they make, what they're interested in, their habits, and what's important to them. This should all be related to the product and how it's meant to be used. Format your response exactly like this:
Targ"&"et Audience for [Instert Product or Service]
Target Audience Description:
Personality Attributes:
Age:
Income:
Interests:
Values:

This is the PRODUCT or SERVICE:"&A2)

Simpler prompts work:

=GPT("Say "&B8)
Cell B8 is "OK" and the response is "OK" so it works

or

=GPT("Say OK")

Any idea what causes the issue in longer prompts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions