Skip to main content

Package with base functionality for llm text creation

Project description



sinapsis-chatbots-base

Package with base support for chat completion tasks

🐍 Installation🚀 Features📚 Usage example📙 Documentation🔍 License

The sinapsis-chatbots-base module provides core functionality for llm chat completion tasks

🐍 Installation

Install using your package manager of choice. We encourage the use of uv

Example with uv:

  uv pip install sinapsis-chatbots-base --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-chatbots-base --extra-index-url https://pypi.sinapsis.tech

[!IMPORTANT] Templates may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:

with uv:

  uv pip install sinapsis-chatbots-base[all] --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-chatbots-base[all] --extra-index-url https://pypi.sinapsis.tech

🚀 Features

* LLMTextCompletionBase: Base class for all templates intended to perform chat (text) completion tasks
🌍 General Attributes

These attributes apply to `LLMTextCompletionBase``:

  • llm_model_name(Required): Name of the LLM to use.
  • n_ctx(Required): Maximum context size.
  • role: Role in the conversation (system, user, or assistant, default: assistant)
  • system_prompt (Optional): Defines the personality of the LLM (e.g., you are a python expert)
  • prompt: Custom instructions to guide the LLM response (default: empty).
  • chat_format: Chat message format (llama-2, chatml, etc., default: chatml).
  • context_max_len: Maximum conversation context length (default: 6).
  • pattern: Regex pattern to match delimiters (default: handles <|...|> and </...>).
  • keep_before: Determines which part of the matched text to return (default: True)
* QueryContextualizeFromFile: Template that adds a certain context to the query searching for keywords in the Documents added in the generic_data field of the DataContainer

[!TIP] Use CLI command sinapsis info --all-template-names to show a list with all the available Template names installed with Sinapsis Data Tools.

[!TIP] Use CLI command sinapsis info --example-template-config TEMPLATE_NAME to produce an example Agent config for the Template specified in TEMPLATE_NAME.

For example, for QueryContextualizeFromFile use sinapsis info --example-template-config QueryContextualizeFromFile to produce the following example config:

agent:
  name: query_contextualize_template
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: QueryContextualizeFromFile
  class_name: QueryContextualizeFromFile
  template_input: InputTemplate
  attributes:
    keywords: '`replace_me:list[str]`'
    generic_keys: '`replace_me:list[str]`'

📚 Usage example

The following agent passes a text message through a TextPacket and checks if there is context with the chosen keyword
Config
agent:
  name: chat_completion
  description: Agent with a chatbot that makes a call to the LLM model using a context uploaded from a file

templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: { }
- template_name: PyPDFLoaderWrapper
  class_name: PyPDFLoaderWrapper
  template_input: InputTemplate
  attributes:
    add_document_as_text_packet: false
    pypdfloader_init:
      file_path: '/path/to/a/file.pdf'

- template_name: TextInput
  class_name: TextInput
  template_input: PyPDFLoaderWrapper
  attributes:
    text: what is AI?
- template_name: QueryContextualizeFromFile
  class_name: QueryContextualizeFromFile
  template_input: TextInput
  attributes:
    keywords: 'Artificial Intelligence'
    generic_keys: 'PyPDFLoaderWrapper

📙 Documentation

Documentation for this and other sinapsis packages is available on the sinapsis website

Tutorials for different projects within sinapsis are available at sinapsis tutorials page

🔍 License

This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.

For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.

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

sinapsis_chatbots_base-0.1.5.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

sinapsis_chatbots_base-0.1.5-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_chatbots_base-0.1.5.tar.gz.

File metadata

File hashes

Hashes for sinapsis_chatbots_base-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a5e33c1f1d518a2183b785e2112b6df1b87693b08a2a93d0907af567f68f9bf1
MD5 8a0fd9add3c8b89e9c20a5b303535e67
BLAKE2b-256 da5476a4754f2d938b10a8bcb0347dd2b22136ae16d64e83485ae82a0c1a1553

See more details on using hashes here.

File details

Details for the file sinapsis_chatbots_base-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_chatbots_base-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 01326e808fce5c4cfc28f75582c992abb04f6d0035fd0092c17951c0f4ac0794
MD5 a0f20d51096072121d8a2ab7f5b296a2
BLAKE2b-256 2815f839831f7f28fd6146a599d20fd657200c19ce071a316293aa904ddf7911

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