LLM Gateway Service
Project description
Feature
- LLM 配置读取远程存储
- Prompt 配置读取远程存储
- LLM 对话记录 存储到远程
- 远程存储: 支持 Baserow
默认使用模式
## 初始化配置
store = BaseRowStore(
api_host=os.environ.get("BASEROW_API_HOST", "localhost"),
api_key=os.environ.get("BASEROW_API_KEY", ""),
db_code="3",
model_table_code="614",
prompt_table_code="308",
chat_log_table_code="309")
llm_gateway = LLMGateway(store)
## 渲染 Prompt 内容
prompt_code = "test_template"
prompt_record, messages = llm_gateway.render_prompt(prompt_code, {"topic": "科幻"})
## LLM 对话
chatCompletion, time_cost = llm_gateway.completions(prompt_record, messages)
print(chatCompletion,time_cost)
## 保存会话记录
trace_id = "1234567890"
log = llm_gateway.save_log(trace_id,prompt_record)
print(log)
轻量使用模式
说明: Prompt 不使用远程存储, 仅 LLM 配置, 对话记录存储到远程
store = BaseRowStore(
api_host=os.environ.get("BASEROW_API_HOST", "localhost"),
api_key=os.environ.get("BASEROW_API_KEY", ""),
db_code="3",
model_table_code="614",
prompt_table_code="308",
chat_log_table_code="309")
llm_gateway = LLMGateway(store)
# 不使用远程 Prompt 模式
messages = [{"role": "system", "content": "今天星期几"}]
# -- 获取 模型信息
model_code = "litellm-us"
model_record = llm_gateway.get_model(model_code)
# -- 执行对话
chatCompletion = llm_gateway.completions(model_record, messages, trace_id="1234567890")
print(chatCompletion)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
llm_store-0.1.4.tar.gz
(7.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_store-0.1.4.tar.gz.
File metadata
- Download URL: llm_store-0.1.4.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d8bc44db6d5157e1969ae15cb6948626ba30c1973554608590cffe9d068c870
|
|
| MD5 |
d9495c791fa97168886fe015b226e77b
|
|
| BLAKE2b-256 |
cde9453c4265cd12748319a2b246f0b0a2453d0dbddf23ff82d47c0dec36e365
|
File details
Details for the file llm_store-0.1.4-py3-none-any.whl.
File metadata
- Download URL: llm_store-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9194e851070bec2ca9d70b174f588686a7fe25098fb5fe309dd8d2279599930
|
|
| MD5 |
1fa21c6dffee2d4a174a8a85ed257cd0
|
|
| BLAKE2b-256 |
761be7495491e940761eda8887874b9ffb7b61c06fea968df567056fc739ff00
|