Skip to main content

大模型辅助函数库

Project description

llmhelper

大模型辅助函数库

安装

pip install llmhelper

环境变量

  • OPENAI_API_KEY
    • 必填
  • OPENAI_BASE_URL
    • 必填
  • OPENAI_CHAT_MODEL
    • 默认为:qwen2-instruct
  • OPENAI_EMBEDDINGS_MODEL
    • 默认为:bge-m3
  • OPENAI_RERANK_MODEL
    • 默认为:bge-reranker-v2-m3
  • LLMHELPER_REDIS_STACK_URLS
    • 默认为:{"default": "redis://localhost:3679/0"}

    • 字典类型,表示指定索引的向量数据库地址。例如:

      LLMHELPER_REDIS_STACK_URLS = {
        "default": "redis://localhost:6379/0",
        "kb:qa": "redis://192.168.1.31:6379/0",
        "kb:doc": "redis://192.168.1.32:6379/0",
        "ai:instruct": "redis://192.168.1.33:6379/0",
      }
      

函数列表

  • exceptions
    • ParseJsonResponseError
    • ChatError
    • GetTextEmbeddingsError
    • GetRerankScoresError
    • NoneValueError
    • VectorStoreNoneValueError
    • EmbeddingsNoneValueError
    • RerankNoneValueError
  • base
    • get_llmhelper_config
    • set_llmhelper_default_config
    • set_llmhelper_config
    • get_default_llm
    • get_default_chat_model
    • get_default_embeddings_model
    • get_default_rerank_model
    • get_template_engine
    • get_llm_base_url
    • get_llm_api_url
  • template
    • get_template_prompt_by_django_template_engine
    • get_template_prompt_by_jinjia2
    • get_template_prompt
  • llm
    • get_messages
    • parse_json_response
    • chat
    • jsonchat
    • streaming_chat
  • embeddings
    • OpenAIEmbeddings
    • get_text_embeddings
  • rerank
    • get_rerank_scores
  • vectorestores
    • RedisVectorStore
  • extra.django_vectorstore_index_model.models
    • WithVectorStoreIndex

版本记录

v0.1.0

  • 版本首发。

v0.2.0

  • 添加embeddings模型操作支持。
  • 添加rerank模型操作支持。

v0.3.0

  • 添加向量数据库操作支持。

v0.4.0

  • 添加django_vectorstore_index_model抽象类。

v0.5.1

新增

  • 添加时间增强数据集。
  • RedisVectorStore.safe_insert函数自动将超长文本分块创建索引。

修改

  • llm.json_parse_response在遇到无法解析的响应时会抛出异常。
  • chat中参数template_name建议修改为template。
  • vectorstores查询空索引时异常,建议异常时返回空数组。
  • get_template_prompt_by_jinjia2允许用户自定义template_root。

修正

  • exception类设定默认提示语的方式错误。
  • llmhelper.template引擎初始化错误。

v0.5.2

修正

  • 时间计算问题。

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

llmhelper-0.5.2.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

llmhelper-0.5.2-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file llmhelper-0.5.2.tar.gz.

File metadata

  • Download URL: llmhelper-0.5.2.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for llmhelper-0.5.2.tar.gz
Algorithm Hash digest
SHA256 ab5db6771c990a91814d26f5efff6baed045bbe937f04c92dfc0fb6206a44e15
MD5 73f0c60f5f4a5f6b80fed845be515ca1
BLAKE2b-256 ca92ce11b6e40d98aae65db0799971b175a0a7dbbcdbae381da7eac7f42fc201

See more details on using hashes here.

File details

Details for the file llmhelper-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: llmhelper-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for llmhelper-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aa8d98c5ff54344a00a1d6d30936382b510d507a6f75506c17bb09af7e002ede
MD5 b631d915b85d8e4fd581e11a1db80c1e
BLAKE2b-256 2110d9f1e3a83327f86ec099e24583cd2b425ef66ac966ae0c7ef86a2a833307

See more details on using hashes here.

Supported by

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