Skip to main content
Delibird

Delibird 是一个多合一大模型接口网关。主要针对国内的大模型,包括文心、百川、千问、星火、智谱等提供统一的接口调用。基于 Python 开发,容易集成。原生提供 Streaming 接口、多进程异步调度模式,性能较好、调用接口完全兼容 openai APi,方便集成。

特点

  • 完全 python 代码,容易修改和集成到项目中
  • 接口简单。兼容 openai 接口,一套接口调用全部模型
  • 支持 http、https 和 websocket 接口
  • 支持几乎全部国内大模型,包括文心、百川、千问、星火、智谱等
  • 支持 Streaming 接口,支持多轮对话
  • 采用 Python asyncio 原生异步和多进程模型,性能较好

支持模型列表

未来计划

  • function calling 支持

使用教程

环境配置

建议基于 python 3.12 以上版本,可以获得更好的性能。具体依赖库可以参考 requirements.txt 文件。

pip install -r requirements.txt

安装

通过 Pypi 安装

pip install delibird

运行

启动服务之前需要配置一个配置文件,文件内设置好对应的模型端口和 api_key。配置文件格式如下:

[server]
host = "localhost"
port = 8000

routers = [
    { name = "spark", driver = "spark" },
    { name = "qwen", driver = "qwen" },
    { name = "ernie", driver = "ernie" },
    { name = "minimax", driver = "minimax" },
    { name = "openai_compatible", driver = "openai" },
]

[driver]
[driver.spark]
# general 指向V1.5版本; generalv2 指向V2版本; generalv3 指向V3版本; generalv3.5 指向V3.5版本;
app_id = "XXX"
api_key = "XXX"
api_secret = "XXX"
url = "wss://spark-api.xf-yun.com"
models = ["general", "generalv2", "generalv3", "generalv3.5"]

[driver.qwen]
api_key = "XXX"
models = ["qwen-turbo", "qweb-plus", "qwen-max"]


[driver.ernie]
appid = 50396495
api_key = "XXX"
secret_key = "XXX"
url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat"
access_token = "XXX"
models = [ "ernie", "ernie-v4", "ernie-8k", "ernie-bot", "ernie-speed", "ernie-bot-turbo",
]

[driver.minimax]
api_key = "XXX"
url = "https://api.minimax.chat/v1/text"
models = ["chatcompletion", "chatcompletion_pro"]

[driver.openai]
api_key = "xxx"
models = ["gpt-3.5-turbo", "gpt-4"]

替换掉上面的 "XXX" 为对应的 api_key 或者其他配置信息。"qwen.max" 后面的 max 代表模型名称,前面的 "qwen" 代表模型服务路由

然后运行服务

delibird start -c config.toml

key.toml 就是配置文件,可以带路径。例如,/home/aaa/delibird/config.toml

停止服务

delibird stop

调用接口

通过 http 调用接口,下面是用 python 的一个例子

from delibird.client import Chat
import asyncio


async def stream_fetch():
    """Test client."""

    messages = [
        {"role": "user", "content": "Python 如何实现异步编程"},
    ]

    host = "localhost"
    port = 8000
    router = "spark"
    url = f"http://{host}:{port}/{router}/chat/completion"

    chat = Chat("v30")

    async for result in chat.stream_fetch(messages, url):
        print(result)


def test_client():
    asyncio.run(stream_fetch())

指定url、模型名称和版本号,然后调用接口即可。

监控页面

版权

基于 Apache-2.0 版权,可以自由使用和修改。

Metadata

Release files for delibird 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for delibird 0.0.10
File Size Uploaded
delibird-0.0.10.tar.gz 29.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for delibird 0.0.10
File Interpreter ABI Platform
delibird-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 37.4 kB

Release files / delibird-0.0.10.tar.gz

Download URL delibird-0.0.10.tar.gz
Size 29.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0a2e4d10ec37f0af1e8ce716cf2ea78541cb1d760171ece349c4b43181decacf
BLAKE2b-256 checksum
How to use checksums
780987d9db6a9757fd5c04c2e7b03304bd4cba7a93321cefa9616057c9d421b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / delibird-0.0.10-py3-none-any.whl

Download URL delibird-0.0.10-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c93672ad00c0e8831d1d68a43062558de592a55df3f6727eb7b40069b788dd17
BLAKE2b-256 checksum
How to use checksums
2c439d9278c5b11224e983a4394dcec09d043cd78135ef157ab372d85d36f2d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page