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引擎初始化错误。

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

Uploaded Source

Built Distribution

llmhelper-0.5.1-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llmhelper-0.5.1.tar.gz
  • Upload date:
  • Size: 18.2 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.1.tar.gz
Algorithm Hash digest
SHA256 64bb358e7286aea0f569e01b81b5535d4bf57f2bd1a7bd5feb4dba0b3e53540c
MD5 aa53ff9e4619d9bd6399aebb450445a0
BLAKE2b-256 0d7a7c0b13562bfe27c397fe377123536086d5d59da240898e2f1d5b2b61dadf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llmhelper-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 21.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8ddf2c55d766d97c3986b1c43850609004937dd2a75a1cf076383b83d6b08b
MD5 a835d781178af25e98eea0281e50533f
BLAKE2b-256 11b14a1c2947946deaf83256c9ef2fc6ecbddfcc3371641457dc2f5d79de190d

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