openai icon indicating copy to clipboard operation
openai copied to clipboard

Support .NET Standard 2.0

Open ricaun opened this issue 2 years ago • 9 comments

Things that were added/changed.

  • Add UnitTest Project for net6.0 and net48
  • Add missing packages for netstandard2.0
  • Change interface methods to extension
  • Change PostAsStreamAsync to async

ricaun avatar Jan 25 '23 21:01 ricaun

thanks for the contribution, but it is quite a big one. Next time if you can create with small changes it would be easier to review.

The first thing I have noticed with these changes we lose the async stream ability. The method waits until the whole response is completed. Please compare in the playground before your changes and after.

kayhantolga avatar Jan 26 '23 22:01 kayhantolga

I found a little odd that the method PostAsStreamAsync was not async, but the name of the method is so I changed. And the netstandard does not have Send method in the client that's the reason I changed, are you sure the method was working async, I try to create a test for test that but I'm not sure if is working like before.

I only changed that was necessary to make work with netstandard, add the Test just to make sure does not break anything.

ricaun avatar Jan 26 '23 23:01 ricaun

Please check this comment (https://github.com/betalgo/openai/pull/73#issuecomment-1385371235). We struggled a bit to make this method work. I will check it to see if it fits with the suggested implementation whenever I have time. currently, in the master branch, it works.

kayhantolga avatar Jan 26 '23 23:01 kayhantolga

with .netstandart2 support, we may need to consider creating a new project in the solution. I just created a discussion about this https://github.com/betalgo/openai/discussions/86. It would be nice to see your thoughts there

kayhantolga avatar Jan 26 '23 23:01 kayhantolga

I gonna create a new branch and create a unit test project to see how the PostAsStreamAsync works without the change.

ricaun avatar Jan 27 '23 12:01 ricaun

I gonna create a new branch and create a unit test project to see how the PostAsStreamAsync works without the change.

I didn't find any difference between the master and the unit_test versions of the CreateCompletionAsStream. I tested it in the Playground and works in the same way...

  • https://github.com/ricaun/openai/tree/unit_test

ricaun avatar Jan 27 '23 13:01 ricaun

I will prepare a video to show the difference as soon as I find some time.

kayhantolga avatar Jan 30 '23 16:01 kayhantolga

https://youtu.be/rGc1X2aD2ms As I promised I made a video. At the first run(current dev branch), you can see stream data shown as soon as we received it. At the second run(your PR) We are waiting for the completion of the entire stream.

kayhantolga avatar Feb 01 '23 23:02 kayhantolga

https://github.com/betalgo/openai/tree/feature/DotNetStandardSupport I have created a new branch for .dotnet standard support. I think it is better to keep it as a separate project. So this way it doesn't slow us while we update the .net 6 project. Currently, there are 5 build time errors in the project, which you already solved in your pr. Could you apply your changes there?

kayhantolga avatar Feb 04 '23 00:02 kayhantolga

Completed in a different branch and released as part of v6.8.0

kayhantolga avatar Mar 14 '23 23:03 kayhantolga