Skip to main content

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

修正

  • 时间计算问题。

v0.5.3

修改

  • WithVectorStoreIndex添加是否自动索引的控制项。

v0.5.4

修改

  • RedisVectorStore添加rerank方法。

v0.5.5

修正

  • parse_json_response正则多行匹配的问题。

Release files for llmhelper 0.5.5

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

Source distribution (sdist)

Source distribution for llmhelper 0.5.5
File Size Uploaded
llmhelper-0.5.5.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llmhelper 0.5.5
File Interpreter ABI Platform
llmhelper-0.5.5-py3-none-any.whl Python 3 none any Details

Total release size: 43.3 kB

Release files / llmhelper-0.5.5.tar.gz

Download URL llmhelper-0.5.5.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cbb0d80dc808bc4586eacef4ab63a98b57b7f09efe227b80bb6df4348757f3a1
BLAKE2b-256 checksum
How to use checksums
bfbd55b8262262d602e944bf342069853e041cfe09b918c0d15fc90d5c2d72e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / llmhelper-0.5.5-py3-none-any.whl

Download URL llmhelper-0.5.5-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80f9e5c55d29b00111d4cca29da076b1c3a399cec5fd339ca8521c5cbd797f67
BLAKE2b-256 checksum
How to use checksums
aeed90bff0ac41c51f8be74168b09fde02ffa7bb9b5a175d88abffce160b2040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.0

2 release files

0.3.0

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