Metadata-Version: 2.1
Name: llm_store
Version: 0.1.4
Summary: LLM Gateway Service
Author: shenyubao
Author-email: shenyubao@yucekj.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: baserowsdk (>=0.0.9,<0.0.10)
Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
Requires-Dist: openai (>=1.54.4,<2.0.0)
Description-Content-Type: text/markdown

# 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 配置, 对话记录存储到远程

```python
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)
```
