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

修正

  • 时间计算问题。

v0.5.3

修改

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

v0.5.4

修改

  • RedisVectorStore添加rerank方法。

v0.5.5

修正

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

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

Uploaded Source

Built Distribution

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

llmhelper-0.5.5-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llmhelper-0.5.5.tar.gz
  • Upload date:
  • Size: 20.3 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.5.tar.gz
Algorithm Hash digest
SHA256 cbb0d80dc808bc4586eacef4ab63a98b57b7f09efe227b80bb6df4348757f3a1
MD5 074f0ca1793af84fddcf0a49076ab0b9
BLAKE2b-256 bfbd55b8262262d602e944bf342069853e041cfe09b918c0d15fc90d5c2d72e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llmhelper-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 23.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 80f9e5c55d29b00111d4cca29da076b1c3a399cec5fd339ca8521c5cbd797f67
MD5 55795635eddafe47a448baa024442730
BLAKE2b-256 aeed90bff0ac41c51f8be74168b09fde02ffa7bb9b5a175d88abffce160b2040

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