Skip to content

feat(oaiapp): 让项目能支持 OpenAI-compatible /v1/chat/completions#344

Closed
RobinRush wants to merge 2 commits into
lsdefine:mainfrom
RobinRush:main
Closed

feat(oaiapp): 让项目能支持 OpenAI-compatible /v1/chat/completions#344
RobinRush wants to merge 2 commits into
lsdefine:mainfrom
RobinRush:main

Conversation

@RobinRush
Copy link
Copy Markdown

Summary

  • 新增 frontends/oaiapp.py:把整个智能体(带工具循环、分层记忆等完整行为)作为一个 OpenAI 风格"模型"暴露出去,任何兼容 OpenAI 接口的客户端(NextChat / Open WebUI / LobeChat / OpenAI SDK / curl 等)即可接入。
  • 支持流式(SSE)与非流式两种模式;零新增依赖(复用已有的 bottle + 标准库 wsgiref 多线程服务器)。
  • launch.pyw 增加 --api 启动开关;mykey_template.py 增加配置示例段;README.md 中英双语补充文档。

Endpoints

  • POST /v1/chat/completions — Chat Completions,支持 stream: true/false
  • GET /v1/models — 列出当前配置的全部 LLM 后端

Configuration (mykey.py)

oai_api_token   = 'sk-local-your-secret-token'   # 必填,Bearer token
# oai_api_host  = '127.0.0.1'                    # 可选;'0.0.0.0' 暴露到局域网
# oai_api_port  = 18000                          # 可选
# oai_api_timeout = 600                          # 可选,单请求超时秒数

@lsdefine
Copy link
Copy Markdown
Owner

Thanks for your contribution! This PR modifies 4 files with +431 lines of changes. To maintain our review quality and adhere to our modularity principles, we prefer smaller, focused PRs. Please consider breaking this into more targeted pieces and resubmitting.

@lsdefine lsdefine closed this May 14, 2026
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

Successfully merging this pull request may close these issues.

2 participants