Chatsky LLM-Autoconfig allows you to effortlessly create chatsky flows and scripts from dialogues using Large Language Models.
You can simply clone this repo and run poetry install to install all dependencies
git clone https://github.com/deeppavlov/chatsky-llm-autoconfig.git
cd chatsky-llm-autoconfig
poetry install
Now you can try to run some scripts or previous experiments to see if everything is working as expected.
To run python file using poetry run the following:
poetry run python <your_file_name>.py
!!! Put your tokens and other sensitive credentials only in .env
files and never hardcode them !!!
./data - Examples, tests and other dialogue data in JSON format
./experiments - Test field for experimental features, test data and results
./scripts - Here we put scripts needed for `poethepoet` automation (you probably do not need to look inside)
./dev_packages/chatsky_llm_autoconfig - Directory containing all the code for the `chatsky_llm_autoconfig` module
Supported types of graphs:
- chain
- single cycle
Currently unsupported types:
- single node cycle
- multi-cycle graph
- incomplete graph
- complex graph with cycles
You can find contribution guideline in CONTRIBUTING.md
You have an example of dialogue from customer chatbot system. You also have an
example of set of rules how chatbot system works should be looking - it is
a set of nodes when chatbot system respons and a set of transitions that are
triggered by user requests.
Here is the example of set of rules:
'edges': [ [ 'source': 1, 'target': 2, 'utterances': 'I need to make an order' ],
[ 'source': 1, 'target': 2, 'utterances': 'I want to order from you' ],
[ 'source': 2, 'target': 3, 'utterances': 'I would like to purchase 'Pale Fire' and 'Anna Karenina', please' ],
'nodes': [ [ 'id': 1, 'label': 'start', 'is_start': true, 'utterances': [ 'How can I help?', 'Hello' ],
[ 'id': 2, 'label': 'ask_books', 'is_start': false, 'utterances': [ 'What books do you like?'] ]
I will give a dialogue, your task is to build a graph for this dialogue in the format above. We allow several edges with equal
source and target and also multiple responses on one node so try not to add new nodes if it is logical just to extend an
exsiting one. utterances in one node or on multiedge should close between each other and correspond to different answers
to one question or different ways to say something. For example, for question about preferences or a Yes/No question
both answers can be fit in one multiedge, there’s no need to make a new node. If two nodes has the same responses they
should be united in one node. Do not make up utterances that aren’t present in the dialogue. Please do not combine
utterances for multiedges in one list, write them separately like in example above. Every utterance from the dialogue,
whether it is from user or assistanst, should contain in one of the nodes. Edges must be utterances from the user. Do not forget ending nodes with goodbyes.
Sometimes dialogue can correspond to several iterations of loop, for example:
['text': 'Do you have apples?', 'participant': 'user'],
['text': 'Yes, add it to your cart?', 'participant': 'assistant'],
['text': 'No', 'participant': 'user'],
['text': 'Okay. Anything else?', 'participant': 'assistant'],
['text': 'I need a pack of chips', 'participant': 'user'],
['text': 'Yes, add it to your cart?', 'participant': 'assistant'],
['text': 'Yes', 'participant': 'user'],
['text': 'Done. Anything else?', 'participant': 'assistant'],
['text': 'No, that’s all', 'participant': 'user'],
it corresponds to following graph:
[ nodes:
'id': 1,
'label': 'confirm_availability_and_ask_to_add',
'is_start': false,
'utterances': 'Yes, add it to your cart?'
],
[
'id': 2,
'label': 'reply_to_yes',
'is_start': false,
'utterances': ['Done. Anything else?', 'Okay. Anything else?']
],
[
'id': 3,
'label': 'finish_filling_cart',
'is_start': false,
'utterances': 'Okay, everything is done, you can go to cart and finish the order.'
],
edges:
[
'source': 1,
'target': 2,
'utterances': 'Yes'
],
[
'source': 1,
'target': 2,
'utterances': 'No'
],
[
'source': 2,
'target': 1,
'utterances': 'I need a pack of chips'
],
[
'source': 2,
'target': 3,
'utterances': 'No, that’s all'
].
We encourage you to use cycles and complex interwining structure of the graph with 'Yes'/'No' edges for the branching.
This is the end of the example. Brackets must be changed back into curly braces to create a valid JSON string. Return ONLY JSON string in plain text (no code blocks) without any additional commentaries.
Dialogue: {dialog}
You have a dialogue and a structure of graph built on this dialogue it is a set of nodes when chatbot system responses and a set of transitions that are triggered by user requests.
Please say if for every utterance in the dialogue there exist either a utteranse in node or in some edge. be attentive to what nodes we actually have in the "nodes" list, because some nodes from the list of edges maybe non existent:
Graph:
Dialogue:
just print the list of utteance and whether there exsit a valid edge of node contating it, if contains print the node or edge
1. You have an example of dialogue from customer chatbot system.
2. You also have a set of rules how chatbot system works - a set of nodes when chatbot system respons and a set of transitions that are triggered by user requests.
3. Chatbot system can move only along transitions listed in 2. If a transition from node A to node B is not listed we cannot move along it.
4. If a dialog doesn't contradcit with the rules listed in 2 print YES otherwise if such dialog could'nt happen because it contradicts the rules print NO. Dialogue: {dialogue}. Set of rules: {rules}