-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Changelog ## Breaking Changes - Dropped support for python 3.8; added support for python 3.12 (#400); - Reworked DB architecture to support partials turn reads/writes (#93). Old Context storages are incompatible with the new ones. See tutorial Context Storages: 8 for more info; - `Context.labels`, `Context.requests`, `Context.responses` are now only lazily loaded (#93). Items from older turns can be loaded on demand. Their `__getitem__` and `get` methods are now async. ## Features - Added `LLMResponse` and `LLMCondition` classes that allow using LLMs (#376). See the new LLM Integration tutorials and LLM user guide for more info; - Added option to extract group slots partially (#394). See tutorial Slots: 2 for more information; - `Message.original_message` is replaced with `Message.origin` which stores both the original message and the interface from which the message originated (#398); - Added `Context.current_turn_id` field which stores the number of the current turn (#93); - Added `Context.created_at`, `Context.updated_at` timestamp fields (#93); - Added `Context.turns` property which allows iterating over requests/labels/responses by their turn ids (#93); - `Context.labels`, `Context.requests`, `Context.responses` now support slicing (#93). `__getitem__`, `__setitem__` and `__delitem__` methods can now accept slices of turn ids in addition to single turn id. `get` method can now accepts iterable of turn ids in addition to single turn id. ## Documentation - Documentation is now versioned (#346, #409). You can select preferred version via the drop-down menu in the top-right corner. ## Developer changes - Context now has field `origin_interface` to store name of the interface that created it (#398); - Added script `docs_no_docker` for building documentation without docker (ef11ff9); - Added in-RAM context storage to be the default one instead of a plain dict (#93); - Removed methods `Context.add_request`, `Context.add_label` and `Context.add_response` (#93). Use setters with `Context.current_turn_id` instead.
- Loading branch information
Showing
150 changed files
with
9,286 additions
and
3,982 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: generate_version_switcher | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["build_and_publish_docs"] | ||
types: | ||
- completed | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
publish: | ||
name: generate and update version switcher's json file | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: install GitPython | ||
run: python -m pip install GitPython | ||
|
||
- name: generate version switcher | ||
env: | ||
VERSION_SWITCHER_STARTING_TAG: ${{ vars.VERSION_SWITCHER_STARTING_TAG }} | ||
VERSION_SWITCHER_TAG_BLACKLIST: ${{ vars.VERSION_SWITCHER_TAG_BLACKLIST }} | ||
VERSION_SWITCHER_TAG_WHITELIST: ${{ vars.VERSION_SWITCHER_TAG_WHITELIST }} | ||
run: | | ||
python ./scripts/switcher_gen.py | ||
- name: copy version switcher for updating it | ||
run: | | ||
mkdir docs/source/switcher/ | ||
cp docs/source/_static/switcher.json docs/source/switcher/switcher.json | ||
- name: update version switcher | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
branch: gh-pages | ||
folder: docs/source/switcher/ | ||
clean: False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
dist/ | ||
venv/ | ||
build/ | ||
dbs/ | ||
docs/source/apiref | ||
docs/source/_misc | ||
docs/source/release_notes.rst | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
""" | ||
LLM Conditions | ||
-------------- | ||
This module provides LLM-based conditions. | ||
""" | ||
|
||
from pydantic import Field | ||
from typing import Optional | ||
|
||
from chatsky.core import BaseCondition, Context | ||
from chatsky.core.script_function import AnyResponse | ||
from chatsky.llm.methods import BaseMethod | ||
from chatsky.llm.langchain_context import get_langchain_context | ||
from chatsky.llm.filters import BaseHistoryFilter, DefaultFilter | ||
from chatsky.llm.prompt import PositionConfig, Prompt | ||
|
||
|
||
class LLMCondition(BaseCondition): | ||
""" | ||
LLM-based condition. | ||
Uses prompt to produce result from model and evaluates the result using given method. | ||
""" | ||
|
||
llm_model_name: str | ||
""" | ||
Key of the model in the :py:attr:`~chatsky.core.pipeline.Pipeline.models` dictionary. | ||
""" | ||
prompt: AnyResponse = Field(default="", validate_default=True) | ||
""" | ||
Condition prompt. | ||
""" | ||
history: int = 1 | ||
""" | ||
Number of dialogue turns aside from the current one to keep in history. `-1` for full history. | ||
""" | ||
filter_func: BaseHistoryFilter = Field(default_factory=DefaultFilter) | ||
""" | ||
Filter function to filter messages in history. | ||
""" | ||
prompt_misc_filter: str = Field(default=r"prompt") | ||
""" | ||
Regular expression to find prompts by key names in MISC dictionary. | ||
""" | ||
position_config: Optional[PositionConfig] = None | ||
""" | ||
Config for positions of prompts and messages in history. | ||
""" | ||
max_size: int = 5000 | ||
""" | ||
Maximum size of any message in chat in symbols. | ||
If a message exceeds the limit it will not be sent to the LLM and a warning | ||
will be produced. | ||
""" | ||
method: BaseMethod | ||
""" | ||
Method that takes model's output and returns boolean. | ||
""" | ||
|
||
async def call(self, ctx: Context) -> bool: | ||
model = ctx.pipeline.models[self.llm_model_name] | ||
|
||
history_messages = [] | ||
history_messages.extend( | ||
await get_langchain_context( | ||
system_prompt=await model.system_prompt(ctx), | ||
ctx=ctx, | ||
call_prompt=Prompt(message=self.prompt), | ||
prompt_misc_filter=self.prompt_misc_filter, | ||
position_config=self.position_config or model.position_config, | ||
length=self.history, | ||
filter_func=self.filter_func, | ||
llm_model_name=self.llm_model_name, | ||
max_size=self.max_size, | ||
) | ||
) | ||
|
||
return await model.condition(history_messages, self.method) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .database import DBContextStorage, threadsafe_method, context_storage_factory | ||
from .json import JSONContextStorage, json_available | ||
from .pickle import PickleContextStorage, pickle_available | ||
from .database import DBContextStorage, context_storage_factory | ||
from .file import JSONContextStorage, PickleContextStorage, ShelveContextStorage, json_available, pickle_available | ||
from .sql import SQLContextStorage, postgres_available, mysql_available, sqlite_available, sqlalchemy_available | ||
from .ydb import YDBContextStorage, ydb_available | ||
from .redis import RedisContextStorage, redis_available | ||
from .memory import MemoryContextStorage | ||
from .mongo import MongoContextStorage, mongo_available | ||
from .shelve import ShelveContextStorage | ||
from .protocol import PROTOCOLS, get_protocol_install_suggestion |
Oops, something went wrong.