国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

Gatewayer worker websocket里面向大模型數(shù)據(jù),socket無法接收用戶數(shù)據(jù)

zhou604638018

問題描述

使用gateway-worker 作為websocket。 當(dāng)worker進(jìn)程里面往GPT(使用的是webman/openai擴(kuò)展),讓GPT按SSE返回?cái)?shù)據(jù),在接收GPT返回?cái)?shù)據(jù)過程當(dāng)中,用戶通過websocket發(fā)送數(shù)據(jù)過來,網(wǎng)關(guān)端可以檢測到數(shù)據(jù)已接收,但是無法給到worker進(jìn)程。直到worker進(jìn)程接收完GPT返回的數(shù)據(jù)之后,此時(shí),worker進(jìn)程才接收到用戶發(fā)送過來的數(shù)據(jù)

代碼

$body = [
            'stream' => true,
            'model' => $model,
            'temperature' => $temperature,
            'messages' => $messages,
            'response_format' => $this->testResponseJson(),
        ];
        $chat = new Chat(['apikey' => $this->openApiKey, 'api' => static::BASE_URI]);
        $audioBusinessService = AudioBusinessMap::getInstance();
        $audioBusinessService->setUid($uid);
        Logger::info(__METHOD__, $messages);
        $lastConversationId = $audioBusinessService->getConversationId();
        $chat->completions($body, [
            'stream' => function ($data) use ($audioBusinessService, $uid, $lastConversationId) {
                static $test = new GptOutStreamDealService('');
                // 當(dāng)openai接口返回?cái)?shù)據(jù)時(shí)轉(zhuǎn)發(fā)給瀏覽器
                $tmpStr = $data['choices'][0]['delta']['content'] ?? '';
                $conversationId = $audioBusinessService->getConversationId();
                if ($conversationId == $lastConversationId) {
                    StoryGamePlayV3Service::streamChat($test, $audioBusinessService, $uid, $tmpStr);
                }
            },
            'complete' => function ($result) use ($historyMap, $audioBusinessService, $uid, $lastConversationId) {
                // 響應(yīng)結(jié)束時(shí)檢查是否有錯(cuò)誤
                $conversationId = $audioBusinessService->getConversationId();
                if ($conversationId == $lastConversationId) {
                    StoryGamePlayV3Service::endChat($result, $historyMap, $audioBusinessService, $uid);
                }

            },
        ]);

public static function streamChat(GptOutStreamDealService $test, AudioBusinessMap $audioBusinessService, int $uid, string $tmpStr): void
    {
        $c = 'Card';
        $m = 'coin';
         if (empty($test->getText())) {
             Log::info(microtime(true) . '大模型第一次吐出詞');
         }
    }
437 1 0
1個(gè)回答

walkor 打賞

通過描述看不出什么,一般是代碼寫的有問題

??