Skip to main content

lmclient

面向于大规模异步请求 OpenAI 接口设计的客户端,使用场景 self-instruct, 大规模翻译等

Features

  1. 支持大规模异步请求 openai 接口
  2. 支持进度条
  3. 支持限制每分钟最大请求次数
  4. 支持限制异步容量 (类似于线程池的大小)
  5. 支持磁盘缓存
  6. 100% type hints
  7. 非常易用
  8. 支持 OpenAI, Azure, Minimax, MinimaxPro, 智谱, 百度文心, 腾讯混元
  9. 支持 FunctionCall

安装方式

支持 python3.8 及以上

pip install lmclient-core

使用方法

  1. CompletionEngine
from lmclient import CompletionEngine, OpenAIChat, OpenAIChatParameters

model = OpenAIChat('gpt-3.5-turbo',  parameters=OpenAIChatParameters(temperature=0))
# 控制每分钟最大请求次数为 20, 异步容量为 5
client = CompletionEngine(model, async_capacity=5, max_requests_per_minute=20)
prompts = [
    'Hello, my name is',
    'can you please tell me your name?',
    [{'role': 'user', 'content': 'hello, who are you?'}],
    'what is your name?',
]
outputs = client.async_run(prompts=prompts)
for output in outputs:
    print(output.reply)
  1. ChatEngine
from lmclient import ChatEngine, OpenAIChat

model = OpenAIChat('gpt-3.5-turbo')
chat_engine = ChatEngine(model)
print(chat_engine.chat('你好,我是 chat_engine'))
print(chat_engine.chat('我上一句话是什么?'))

Metadata

Release files for lmclient-core 0.8.4

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

Source distribution (sdist)

Source distribution for lmclient-core 0.8.4
File Size Uploaded
lmclient_core-0.8.4.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lmclient-core 0.8.4
File Interpreter ABI Platform
lmclient_core-0.8.4-py3-none-any.whl Python 3 none any Details

Total release size: 53.7 kB

Release files / lmclient_core-0.8.4.tar.gz

Download URL lmclient_core-0.8.4.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b687543dfb63da2674aae9a09a796944f28ed7d7636b927fb56533c999e6c620
BLAKE2b-256 checksum
How to use checksums
1fcc73ca958d49bf913883eb65c58050f93526ff8479fe4d2eed50489fcb92f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.0 Linux/6.2.0-1015-azure

Release files / lmclient_core-0.8.4-py3-none-any.whl

Download URL lmclient_core-0.8.4-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bd726a51a2d413a905b26f9b8f1cb841a48e2521344e86cde69dea4aa4dec64
BLAKE2b-256 checksum
How to use checksums
545b2373263b03f39000f339214cce47023e0b3af24efef030ccde8c3af9ddd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.0 Linux/6.2.0-1015-azure

Release history Release notifications | RSS feed

This release

0.8.4 This release

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

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