ChatGPTNextWeb / ChatGPTNextWeb/NextChat

[Feature Request] OpenAI Realtime API

Open
#5,672 13 comments 0 reactions 3 assignees Claimed by @Leizhenpeng View on GitHub
enhancement
Dominant language
TypeScript
Stars
88.8k
Forks
59.1k
PR merge metrics
No merged PRs in 30d

Description

### 🥰 需求描述

https://openai.com/index/introducing-the-realtime-api/

https://platform.openai.com/docs/api-reference/realtime

https://github.com/openai/openai-realtime-console/blob/main/readme/realtime-console-demo.png

![image](https://raw.githubusercontent.com/openai/openai-realtime-console/refs/heads/main/readme/realtime-console-demo.png)

### 🧐 解决方案

# 逻辑
1. realtime api,使用websocket接入
2. api本身内置了`sessions`, `conversation`等概念,session支持配置modalities, instructions, voice, input_audio_format, output_audio_format, turn_detection, input_audio_transcription, tools等,支持function call
3. 支持`input_audio_buffer.append`以及`input_audio_buffer.commit`方式上传音频,再通过`response.create`开始生成结果(turn_detection如果开启,可以不用手动调用)
4. 支持客户端发送`conversation.item.create`将上下文的内容直接添加到当前的conversation,如果是历史记录,需要设置status=completed
5. `conversation.item.truncate`支持打断输入
6. 通过监听事件`response.audio.delta`拿到base64 audio data,通过`response.text.delta`同步拿到文本。
7. 通过监听事件`response.output_item.added`拿到是否是function call, 通过监听`response.function_call_arguments.delta`拿到function call参数。或者直接在`response.done`里面拿function call相关信息?

# 交互
1. 可能会新增OpenAI客户端一样的语音交互页面直接调用realtime api。
2. 当前的语音交互界面,默认全屏,支持缩小到输入框大小(替换输入框位置)。同时保留语音输入界面以及chat history页面(保留这里,可以支持展示插件执行生成的中间结果等,例如中间调用插件生成一张图,语音是无法直接描述的)。
3. 语音通话生成的结果(audio buffer)以及同时拿到的文本信息,需要持久化到sessions里面
4. 语音通话支持选择voice,format,detection模式,tools等(这些按钮需要保留,或者在语音界面重新布局)

# 讨论
1. realtime是一个新的model,但是这个model明显和之前的model是不对等的。应该怎么放?
2. realtime api也支持modalities只填写text,会将语音给屏蔽掉(只是屏蔽语音,但还是支持一整套的通过websocket调用这个模型)。

### 📝 补充信息

价格
![image](https://github.com/user-attachments/assets/4251ae42-7dfc-456a-a821-dd56d0569798)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.