srcnalt/OpenAI-Unity

Build for Oculus Quest 3 not giving a response from OpenAI

Opened this issue · 11 comments

Hey,

I encountered an issue that only shows in my build, everything works fine in unity but in the build the messages are not getting through nothing is being displayed as a text so I am asuming that also the AWS just does not work because of this, however my animation is being triggered.

I building for Android for the Quest 2/3 as my game is in augmented reality.

normally a message should appear and the sound clip from AWS should play, which again, works fine inside of unity but not in the build.

does anybody know what the issue could be here? is it a permission issue?

issue.mp4

Hi @Nixer087 could you check project settings to see if internet is allowed?

it is set on auto
image (1)

I'm also not seeing it in my xr Plug-in manager

image

Can you make internet always and try?

I changed the setting to internet required and built it, and still no luck I'm afraid.
image

Can you debug it via logcat? See if there are any error messages?

Iquickly tested it and it sais I do not have an API key 
You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.

though it is in the script but not in a separate script, I put it in the ChatGPT script

So did it work at the end? You should put it in there like this:
var openai = new OpenAIApi("sk-Me8...6yi");

I am unable to test it until the 20th. But I think it will probably do the trick, I also had to change the manifest for it to allow internet and read and write locally .I will let you know as soon as It is fixed.

I had the same problem with Quest 3 glasses. I,m building an educational game with my students where player can practise different educational skills by talking with avatars in a friendly environment. My students found out that this is a datatype -error.

When we added one line of code to Datatypes.sc OPenAI started responding again. Here is our solution:

public string? refusal { get; set; }

This line must be in the ChatMessage function like this:

public struct ChatMessage
{
public string Role { get; set; }
public string Content { get; set; }
public string? refusal { get; set; }
}

and the Datatypes -script can be found in

Packages/OpenAI Unity/Runtime

We hope this helps :)

so to conclude, I did put the OpenAIApi Keys in the code in the end as it was still in a Json file outside my build.
So adding it to the dit OpenAIApi script the trick! Here is where I put it:

    public Configuration(string apiKey = null, string organization = null)
    {
        if (apiKey == null)
        {
            Auth = new Auth()
            {
                ApiKey = "sk******gn7",
                Organization = "org-m***f"
            };

Thanks for your help!^^