Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request streaming breaks Openai API response #6

Open
ddnetters opened this issue Feb 14, 2024 · 1 comment
Open

Request streaming breaks Openai API response #6

ddnetters opened this issue Feb 14, 2024 · 1 comment

Comments

@ddnetters
Copy link

When using the plugin to translate text the GenerateController::actionIndex() returns the following. Would just sending and waiting for the request suffice instead of streaming it? It'd remove some complexity and users have to wait for the final result anyways.

data: {"id":"****","object":"chat.completion.chunk","created":1707917150,"model":"gpt-4-0613","system_fingerprint":null,"choices":[{"index":0,"delta":{"rol
data: null

data: null

data: null

data: null

data: null

data: null

data: null

data: null

data: null

data: null

<pre>An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/html/vendor/mostlyserious/craft-promptly/src/Controllers/Traits/HasFetching.php on line 83. in /var/www/html/vendor/yiisoft/yii2/web/Response.php:369
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/web/Response.php(342): yii\web\Response-&gt;sendHeaders()
#1 /var/www/html/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response-&gt;send()
#2 /var/www/html/vendor/craftcms/cms/src/web/ErrorHandler.php(192): yii\web\ErrorHandler-&gt;renderException(Object(yii\web\HeadersAlreadySentException))
#3 /var/www/html/vendor/yiisoft/yii2/base/ErrorHandler.php(152): craft\web\ErrorHandler-&gt;renderException(Object(yii\web\HeadersAlreadySentException))
#4 /var/www/html/vendor/craftcms/cms/src/web/ErrorHandler.php(66): yii\base\ErrorHandler-&gt;handleException(Object(yii\web\HeadersAlreadySentException))
#5 [internal function]: craft\web\ErrorHandler-&gt;handleException(Object(yii\web\HeadersAlreadySentException))
#6 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/html/vendor/mostlyserious/craft-promptly/src/Controllers/Traits/HasFetching.php on line 83. in /var/www/html/vendor/yiisoft/yii2/web/Response.php:369
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/web/Response.php(342): yii\web\Response-&gt;sendHeaders()
#1 /var/www/html/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response-&gt;send()
#2 /var/www/html/web/index.php(33): yii\base\Application-&gt;run()
#3 {main}</pre>
@corneliusio
Copy link
Collaborator

@ddnetters Yeah, working with streaming in PHP has been a chore and unfortunately this was pretty much the first go at an OpenAI integration. Would agree but we had a number of other stakeholders who felt streaming would be important for perceived performance. I've had the opportunity to work on a number of other OpenAI integrations since initially releasing this plugin and will be coming back through to refactor quite a bit to improve these hiccups. At the moment my agency is slammed with development work and I haven't been able to dedicate the time I'd like to making improvements here but it is at the top of my list of priorities as soon as I have the chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants