Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Conflict with 'IAsyncEnumerable<T>' in Unity When Integrating OpenAI GPT API Wrapper

Discussion in 'Editor & General Support' started by OneHelluvaGuy, Jul 6, 2023.

  1. OneHelluvaGuy

    OneHelluvaGuy

    Joined:
    Feb 27, 2023
    Posts:
    5
    I am currently working on a Unity 2D game project (version 2022.2.6f1) where I'm trying to integrate the OpenAI GPT-3 API using an C#/.NET wrapper library, version 1.6 https://github.com/OkGoDoIt/OpenAI-API-dotnet. This wrapper requires .NET Standard 2.0 but my project's API compatibility level is .NET Standard 2.1, this may be the issue but I am not sure, I also don't know if that's fixable. I'm encountering an issue with 'IAsyncEnumerable' that seems to exist in both 'System.Interactive.Async' and 'netstandard'. Here is the exact error I'm getting:

    Assets\3rd Party\OkGoDoIt\OpenAI_API\Completions\CompletionEndpoint.cs(153,10): error CS0433: The type 'IAsyncEnumerable' exists in both 'System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263' and 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

    I've added the Newtonsoft.Json 12.0.1 dll file and the 1.6 version of the chat GPT wrapper folder OpenAI_API to the assets of my Unity project. In the Player preferences API compatibility level in Unity I tried to go from .NET Standard 2.1 to the only other choice i have there: .NET Framework but it didn't change anything. I tried changing the .csproj so I can make an alias and force my project to always use IAsyncEnumerable from only System.Interactive.Async but every code I write there Unity just reloads it to the previous version.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    What does chat say about the problem? :)
     
  3. OneHelluvaGuy

    OneHelluvaGuy

    Joined:
    Feb 27, 2023
    Posts:
    5
    If you are talking about Chat GPT, it really isn't of much help, I tried many times with it
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
  5. OneHelluvaGuy

    OneHelluvaGuy

    Joined:
    Feb 27, 2023
    Posts:
    5
    Thanks for trying to help. Indeed, that was a good path I also followed with chat gpt. I am able to solve this in Visual Studio by adding an alias to System.Interactive.Async, I rebuild and all of the errors dissapear. However, I go into Unity afterwards, the errors are still there, when I double click them I am sent back to VS where I can see the change I made was reverted, the alias for System.Interactive.Async is back to global and I am back to the same errors.
    Is there any way to keep those changes even after exiting VS? I have the same issue with .csproj file.
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    This is one of those quirks working in Unity. Unity doesn't rely on or care about Visual Studio. Unity is happy if you used Notepad to edit your C# files.

    The only errors that matter are what come up in the Unity log.

    So what you must do is (somehow) cause config changes in Unity to result in the final outcome you have already proven in Visual Studios. This may be in the form of assembly definitions in Unity, or perhaps other build tool extensions, but alas I am out of my depth on this sort of integration.

    Perhaps someone else can chime in here?

    EDIT: duh... or ask Chat? :)
     
  7. OneHelluvaGuy

    OneHelluvaGuy

    Joined:
    Feb 27, 2023
    Posts:
    5
    yes this is exactly what I would want... I am discovering this dark side of Unity and I do not like it haha. I talked yesterday and today all the time with chat gpt premium I really tried that path but at the moment someone who would be familiar with this in Unity would be much better to help