Comments (1)
I also had that error, I managed to modify the source code to solve it, I changed the stop logic of the cycle that received the streams, I attach the modified code fragment of the OpenAIApi.cs that is inside Runtime so that you can add it and test it. I have already generated the pr to be added to the source code.
Script :
/// <summary>
/// Dispatches an HTTP request to the specified path with the specified method and optional payload.
/// </summary>
/// <param name="path">The path to send the request to.</param>
/// <param name="method">The HTTP method to use for the request.</param>
/// <param name="onResponse">A callback function to be called when a response is updated.</param>
/// <param name="onComplete">A callback function to be called when the request is complete.</param>
/// <param name="token">A cancellation token to cancel the request.</param>
/// <param name="payload">An optional byte array of json payload to include in the request.</param>
private async void DispatchRequest<T>(string path, string method, Action<List<T>> onResponse, Action onComplete, CancellationTokenSource token, byte[] payload = null) where T: IResponse
{
using (var request = UnityWebRequest.Put(path, payload))
{
request.method = method;
request.SetHeaders(Configuration, ContentType.ApplicationJson);
request.SendWebRequest();
bool isDone = false;
do
{
List<T> dataList = new List<T>();
string[] lines = request.downloadHandler.text.Split('\n').Where(line => line != "").ToArray();
foreach (string line in lines)
{
var value = line.Replace("data: ", "");
if (value.Contains("stop"))
{
isDone = true;
break;
}
var data = JsonConvert.DeserializeObject<T>(value, jsonSerializerSettings);
if (data?.Error != null)
{
ApiError error = data.Error;
Debug.LogError($"Error Message: {error.Message}\nError Type: {error.Type}\n");
}
else
{
dataList.Add(data);
}
}
onResponse?.Invoke(dataList);
await Task.Yield();
}
while (!isDone);
onComplete?.Invoke();
}
}
from openai-unity.
Related Issues (20)
- JsonSerializationException: Could not find member 'system_fingerprint' on object of type 'CreateChatCompletionResponse'. Path 'system_fingerprint', line 21, position 23. HOT 5
- OpenAI Text To Speech Support? HOT 5
- OpenAI Whisper Broken
- JSON Mode HOT 8
- logprobs missing from datatype ChatChoice HOT 8
- JsonSerializationException: Could not find member 'logprobs' on object of type 'ChatChoice'. Path 'choices[0].logprobs', line 13, position 17. HOT 3
- JsonSerializationException: Could not find member 'logprobs' on object of type 'ChatChoice'. Path 'choices[0].logprobs', line 1, position 231. HOT 1
- JsonSerializationException: Could not find member 'logprobs' on object of type 'ChatChoice'. HOT 3
- JSON Serialization Exception on Android, Not in Editor HOT 3
- Chat GPT in VR working? HOT 3
- JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
- JsonSerializationException: No JSON content found and type 'OpenAI.CreateAudioResponse' is not nullable. Path '', line 0, position 0. HOT 5
- [FEATURE REQUEST] Add ToolChoice to CreateRunRequest method
- Import Error in Unity HOT 10
- GPT 4 Model HOT 5
- JsonSerializationException on CreateChatCompletion HOT 2
- Assistants API?
- Dall-E 3 HOT 1
- How to solve GPT-4 turbo (gpt-4-1106-preview) error HOT 4
- Meeting error with JsonSerializationException when trying the ChatCompletion HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openai-unity.