Skip to main content

LLM Gateway Service

Project description

Feature

  • LLM 配置读取远程存储
  • Prompt 配置读取远程存储
  • LLM 对话记录 存储到远程
  • 远程存储: 支持 Baserow
  • 支持使用 Jinja2 模板渲染 Prompt

使用示例

from llm_store.gateway import LLMGateway
from llm_store.store.baserowstore import BaseRowStore
import os

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_code = "system_blank"

# -- 获取 AI 模型
llm_model = llm_gateway.get_model(prompt_code)

# -- 渲染 Prompt
messages = llm_gateway.render_prompt(prompt_code, {"content": "你是谁"})

# -- 执行对话
chatCompletion = llm_gateway.completions(llm_model, messages, trace_id="1234567890")
print(chatCompletion)

约定

内置Prompt_code

  • system_blank: 格式为 {{content}} , 模型为小参数模型, 一般为 4o-mini
  • system_blank_advanced: 格式为: {{content}}, 模型为大参数模型, 一般为 4o

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.7.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_store-0.1.7-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file llm_store-0.1.7.tar.gz.

File metadata

  • Download URL: llm_store-0.1.7.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.5.0

File hashes

Hashes for llm_store-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b24e6605f5a751e9d2b3c5e1f0c3db3dd4fdee2ff0a7e1a5afa5753d2681338a
MD5 5019e7125e1f2249ff6b46dcd1ac0a16
BLAKE2b-256 af4cebb6b02ddab2cb9d8b601dff1ccf3c1ce591e25f015a1f56cffd6e8a306b

See more details on using hashes here.

File details

Details for the file llm_store-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: llm_store-0.1.7-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

Hashes for llm_store-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 441ae74ee3756240ff11899ed6c45cde3ab1907f61d155c0d2eb57febc401001
MD5 8d7c00f6fe34e1a1ce5f9cdc1f2ef3ff
BLAKE2b-256 388a5ffcc75f902853335e86b53bc43d6c9896907c73f28922cc9eb29feb1881

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page