Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #8

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
RASA_PRO_LICENSE='your_rasa_pro_license_key_here'
OPENAI_API_KEY='your_openai_api_key_here'
RASA_PRO_LICENSE='eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjZTk0MGRjMi0zMmJhLTRjM2EtYWE2My01ODAyNWI0YjFhZmIiLCJpYXQiOjE3MzQ0Mzk5NzUsIm5iZiI6MTczNDQzOTk3MSwic2NvcGUiOiJyYXNhOnBybyByYXNhOnBybzpjaGFtcGlvbiIsImV4cCI6MTgyOTA0Nzk3MSwiZW1haWwiOiJkYW5pZWxlLmRlZ3ZvaWNlQGdtYWlsLmNvbSIsImNvbXBhbnkiOiJSYXNhIENoYW1waW9ucyJ9.yT1AtBBeKyKAxekCCd8wHGSb3Wjd-dCnaU18lHS_ab3M1CmFQkkC-0bQANtor7rYbZKdMEEPUW9G8NZu3wHODEWgUFBP0cau4zjpcTgBQVMBJcfFg59SZa2LmLr0bPjDEiLqO6SO9I3-OLeBdEhm7Tx386leuGyz0xrVE7JshylVXQ8YNWNJgFxQKRPwoWK2YHR1oUDKyVP2l8Uo9AbCyZTGjQt9WwAk7poiqxSRdFDJHVCXSrC4rRejTgMhTaBCu2DbL52o0nsSs1r95k_Dlgvg0rvZBvuGgb4AihV_r12vEykg6CKbtKDZuYW5hxl-njI4tl9tGDnhlPtuNoLuhA'
HUGGINGFACE_API_KEY='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'
OPENAI_API_KEY='open_here'
Binary file added .rasa/cache/cache.db
Binary file not shown.
Binary file added .rasa/cache/rasa-llm-cache/cache.db
Binary file not shown.
Binary file added .rasa/cache/rasa-llm-cache/cache.db-shm
Binary file not shown.
Binary file added .rasa/cache/rasa-llm-cache/cache.db-wal
Binary file not shown.
60 changes: 60 additions & 0 deletions .rasa/cache/tmpmcpc3ms2/command_prompt.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.

These are the flows that can be started, with their description and slots:
{% for flow in available_flows %}
{{ flow.name }}: {{ flow.description }}
{% for slot in flow.slots -%}
slot: {{ slot.name }}{% if slot.description %} ({{ slot.description }}){% endif %}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{%- endfor %}

===
Here is what happened previously in the conversation:
{{ current_conversation }}

===
{% if current_flow != None %}
You are currently in the flow "{{ current_flow }}".
You have just asked the user for the slot "{{ current_slot }}"{% if current_slot_description %} ({{ current_slot_description }}){% endif %}.

{% if flow_slots|length > 0 %}
Here are the slots of the currently active flow:
{% for slot in flow_slots -%}
- name: {{ slot.name }}, value: {{ slot.value }}, type: {{ slot.type }}, description: {{ slot.description}}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{% endif %}
{% else %}
You are currently not in any flow and so there are no active slots.
This means you can only set a slot if you first start a flow that requires that slot.
{% endif %}
If you start a flow, first start the flow and then optionally fill that flow's slots with information the user provided in their message.

The user just said """{{ user_message }}""".

===
Based on this information generate a list of actions you want to take. Your job is to start flows and to fill slots where appropriate. Any logic of what happens afterwards is handled by the flow engine. These are your available actions:
* Slot setting, described by "SetSlot(slot_name, slot_value)". An example would be "SetSlot(recipient, Freddy)"
* Starting another flow, described by "StartFlow(flow_name)". An example would be "StartFlow(transfer_money)"
* Cancelling the current flow, described by "CancelFlow()"
* Clarifying which flow should be started. An example would be Clarify(list_contacts, add_contact, remove_contact) if the user just wrote "contacts" and there are multiple potential candidates. It also works with a single flow name to confirm you understood correctly, as in Clarify(transfer_money).
* Intercepting and handle user messages with the intent to bypass the current step in the flow, described by "SkipQuestion()". Examples of user skip phrases are: "Go to the next question", "Ask me something else".
* Responding to knowledge-oriented user messages, described by "SearchAndReply()"
* Responding to a casual, non-task-oriented user message, described by "ChitChat()".
* Handing off to a human, in case the user seems frustrated or explicitly asks to speak to one, described by "HumanHandoff()".
{% if is_repeat_command_enabled %}
* Repeat the last bot messages, described by "RepeatLastBotMessages()". This is useful when the user asks to repeat the last bot messages.
{% endif %}

===
Write out the actions you want to take, one per line, in the order they should take place.
Do not fill slots with abstract values or placeholders.
Only use information provided by the user.
Only start a flow if it's completely clear what the user wants. Imagine you were a person reading this message. If it's not 100% clear, clarify the next step.
Don't be overly confident. Take a conservative approach and clarify before proceeding.
If the user asks for two things which seem contradictory, clarify before starting a flow.
If it's not clear whether the user wants to skip the step or to cancel the flow, cancel the flow.
Strictly adhere to the provided action types listed above.
Focus on the last message and take it one step at a time.
Use the previous conversation steps only to aid understanding.

Your action list:
20 changes: 20 additions & 0 deletions .rasa/cache/tmpmcpc3ms2/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"prompt": null,
"prompt_template": null,
"user_input": null,
"llm": {
"provider": "rasa",
"model": "rasa/cmd_gen_codellama_13b_calm_demo",
"api_base": "https://tutorial-llm.rasa.ai"
},
"flow_retrieval": {
"embeddings": {
"provider": "openai",
"model": "text-embedding-ada-002"
},
"num_flows": 20,
"turns_to_embed": 1,
"should_embed_slots": true,
"active": false
}
}
60 changes: 60 additions & 0 deletions .rasa/cache/tmpobyk2ibs/command_prompt.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.

These are the flows that can be started, with their description and slots:
{% for flow in available_flows %}
{{ flow.name }}: {{ flow.description }}
{% for slot in flow.slots -%}
slot: {{ slot.name }}{% if slot.description %} ({{ slot.description }}){% endif %}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{%- endfor %}

===
Here is what happened previously in the conversation:
{{ current_conversation }}

===
{% if current_flow != None %}
You are currently in the flow "{{ current_flow }}".
You have just asked the user for the slot "{{ current_slot }}"{% if current_slot_description %} ({{ current_slot_description }}){% endif %}.

{% if flow_slots|length > 0 %}
Here are the slots of the currently active flow:
{% for slot in flow_slots -%}
- name: {{ slot.name }}, value: {{ slot.value }}, type: {{ slot.type }}, description: {{ slot.description}}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{% endif %}
{% else %}
You are currently not in any flow and so there are no active slots.
This means you can only set a slot if you first start a flow that requires that slot.
{% endif %}
If you start a flow, first start the flow and then optionally fill that flow's slots with information the user provided in their message.

The user just said """{{ user_message }}""".

===
Based on this information generate a list of actions you want to take. Your job is to start flows and to fill slots where appropriate. Any logic of what happens afterwards is handled by the flow engine. These are your available actions:
* Slot setting, described by "SetSlot(slot_name, slot_value)". An example would be "SetSlot(recipient, Freddy)"
* Starting another flow, described by "StartFlow(flow_name)". An example would be "StartFlow(transfer_money)"
* Cancelling the current flow, described by "CancelFlow()"
* Clarifying which flow should be started. An example would be Clarify(list_contacts, add_contact, remove_contact) if the user just wrote "contacts" and there are multiple potential candidates. It also works with a single flow name to confirm you understood correctly, as in Clarify(transfer_money).
* Intercepting and handle user messages with the intent to bypass the current step in the flow, described by "SkipQuestion()". Examples of user skip phrases are: "Go to the next question", "Ask me something else".
* Responding to knowledge-oriented user messages, described by "SearchAndReply()"
* Responding to a casual, non-task-oriented user message, described by "ChitChat()".
* Handing off to a human, in case the user seems frustrated or explicitly asks to speak to one, described by "HumanHandoff()".
{% if is_repeat_command_enabled %}
* Repeat the last bot messages, described by "RepeatLastBotMessages()". This is useful when the user asks to repeat the last bot messages.
{% endif %}

===
Write out the actions you want to take, one per line, in the order they should take place.
Do not fill slots with abstract values or placeholders.
Only use information provided by the user.
Only start a flow if it's completely clear what the user wants. Imagine you were a person reading this message. If it's not 100% clear, clarify the next step.
Don't be overly confident. Take a conservative approach and clarify before proceeding.
If the user asks for two things which seem contradictory, clarify before starting a flow.
If it's not clear whether the user wants to skip the step or to cancel the flow, cancel the flow.
Strictly adhere to the provided action types listed above.
Focus on the last message and take it one step at a time.
Use the previous conversation steps only to aid understanding.

Your action list:
20 changes: 20 additions & 0 deletions .rasa/cache/tmpobyk2ibs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"prompt": null,
"prompt_template": null,
"user_input": null,
"llm": {
"provider": "rasa",
"model": "rasa/cmd_gen_codellama_13b_calm_demo",
"api_base": "https://tutorial-llm.rasa.ai"
},
"flow_retrieval": {
"embeddings": {
"provider": "openai",
"model": "text-embedding-ada-002"
},
"num_flows": 20,
"turns_to_embed": 1,
"should_embed_slots": true,
"active": false
}
}
60 changes: 60 additions & 0 deletions .rasa/cache/tmpvmyhfpi3/command_prompt.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.

These are the flows that can be started, with their description and slots:
{% for flow in available_flows %}
{{ flow.name }}: {{ flow.description }}
{% for slot in flow.slots -%}
slot: {{ slot.name }}{% if slot.description %} ({{ slot.description }}){% endif %}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{%- endfor %}

===
Here is what happened previously in the conversation:
{{ current_conversation }}

===
{% if current_flow != None %}
You are currently in the flow "{{ current_flow }}".
You have just asked the user for the slot "{{ current_slot }}"{% if current_slot_description %} ({{ current_slot_description }}){% endif %}.

{% if flow_slots|length > 0 %}
Here are the slots of the currently active flow:
{% for slot in flow_slots -%}
- name: {{ slot.name }}, value: {{ slot.value }}, type: {{ slot.type }}, description: {{ slot.description}}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{% endif %}
{% else %}
You are currently not in any flow and so there are no active slots.
This means you can only set a slot if you first start a flow that requires that slot.
{% endif %}
If you start a flow, first start the flow and then optionally fill that flow's slots with information the user provided in their message.

The user just said """{{ user_message }}""".

===
Based on this information generate a list of actions you want to take. Your job is to start flows and to fill slots where appropriate. Any logic of what happens afterwards is handled by the flow engine. These are your available actions:
* Slot setting, described by "SetSlot(slot_name, slot_value)". An example would be "SetSlot(recipient, Freddy)"
* Starting another flow, described by "StartFlow(flow_name)". An example would be "StartFlow(transfer_money)"
* Cancelling the current flow, described by "CancelFlow()"
* Clarifying which flow should be started. An example would be Clarify(list_contacts, add_contact, remove_contact) if the user just wrote "contacts" and there are multiple potential candidates. It also works with a single flow name to confirm you understood correctly, as in Clarify(transfer_money).
* Intercepting and handle user messages with the intent to bypass the current step in the flow, described by "SkipQuestion()". Examples of user skip phrases are: "Go to the next question", "Ask me something else".
* Responding to knowledge-oriented user messages, described by "SearchAndReply()"
* Responding to a casual, non-task-oriented user message, described by "ChitChat()".
* Handing off to a human, in case the user seems frustrated or explicitly asks to speak to one, described by "HumanHandoff()".
{% if is_repeat_command_enabled %}
* Repeat the last bot messages, described by "RepeatLastBotMessages()". This is useful when the user asks to repeat the last bot messages.
{% endif %}

===
Write out the actions you want to take, one per line, in the order they should take place.
Do not fill slots with abstract values or placeholders.
Only use information provided by the user.
Only start a flow if it's completely clear what the user wants. Imagine you were a person reading this message. If it's not 100% clear, clarify the next step.
Don't be overly confident. Take a conservative approach and clarify before proceeding.
If the user asks for two things which seem contradictory, clarify before starting a flow.
If it's not clear whether the user wants to skip the step or to cancel the flow, cancel the flow.
Strictly adhere to the provided action types listed above.
Focus on the last message and take it one step at a time.
Use the previous conversation steps only to aid understanding.

Your action list:
20 changes: 20 additions & 0 deletions .rasa/cache/tmpvmyhfpi3/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"prompt": null,
"prompt_template": null,
"user_input": null,
"llm": {
"provider": "rasa",
"model": "rasa/cmd_gen_codellama_13b_calm_demo",
"api_base": "https://tutorial-llm.rasa.ai"
},
"flow_retrieval": {
"embeddings": {
"provider": "openai",
"model": "text-embedding-ada-002"
},
"num_flows": 20,
"turns_to_embed": 1,
"should_embed_slots": true,
"active": false
}
}
60 changes: 60 additions & 0 deletions .rasa/cache/tmpydlqtcg0/command_prompt.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.

These are the flows that can be started, with their description and slots:
{% for flow in available_flows %}
{{ flow.name }}: {{ flow.description }}
{% for slot in flow.slots -%}
slot: {{ slot.name }}{% if slot.description %} ({{ slot.description }}){% endif %}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{%- endfor %}

===
Here is what happened previously in the conversation:
{{ current_conversation }}

===
{% if current_flow != None %}
You are currently in the flow "{{ current_flow }}".
You have just asked the user for the slot "{{ current_slot }}"{% if current_slot_description %} ({{ current_slot_description }}){% endif %}.

{% if flow_slots|length > 0 %}
Here are the slots of the currently active flow:
{% for slot in flow_slots -%}
- name: {{ slot.name }}, value: {{ slot.value }}, type: {{ slot.type }}, description: {{ slot.description}}{% if slot.allowed_values %}, allowed values: {{ slot.allowed_values }}{% endif %}
{% endfor %}
{% endif %}
{% else %}
You are currently not in any flow and so there are no active slots.
This means you can only set a slot if you first start a flow that requires that slot.
{% endif %}
If you start a flow, first start the flow and then optionally fill that flow's slots with information the user provided in their message.

The user just said """{{ user_message }}""".

===
Based on this information generate a list of actions you want to take. Your job is to start flows and to fill slots where appropriate. Any logic of what happens afterwards is handled by the flow engine. These are your available actions:
* Slot setting, described by "SetSlot(slot_name, slot_value)". An example would be "SetSlot(recipient, Freddy)"
* Starting another flow, described by "StartFlow(flow_name)". An example would be "StartFlow(transfer_money)"
* Cancelling the current flow, described by "CancelFlow()"
* Clarifying which flow should be started. An example would be Clarify(list_contacts, add_contact, remove_contact) if the user just wrote "contacts" and there are multiple potential candidates. It also works with a single flow name to confirm you understood correctly, as in Clarify(transfer_money).
* Intercepting and handle user messages with the intent to bypass the current step in the flow, described by "SkipQuestion()". Examples of user skip phrases are: "Go to the next question", "Ask me something else".
* Responding to knowledge-oriented user messages, described by "SearchAndReply()"
* Responding to a casual, non-task-oriented user message, described by "ChitChat()".
* Handing off to a human, in case the user seems frustrated or explicitly asks to speak to one, described by "HumanHandoff()".
{% if is_repeat_command_enabled %}
* Repeat the last bot messages, described by "RepeatLastBotMessages()". This is useful when the user asks to repeat the last bot messages.
{% endif %}

===
Write out the actions you want to take, one per line, in the order they should take place.
Do not fill slots with abstract values or placeholders.
Only use information provided by the user.
Only start a flow if it's completely clear what the user wants. Imagine you were a person reading this message. If it's not 100% clear, clarify the next step.
Don't be overly confident. Take a conservative approach and clarify before proceeding.
If the user asks for two things which seem contradictory, clarify before starting a flow.
If it's not clear whether the user wants to skip the step or to cancel the flow, cancel the flow.
Strictly adhere to the provided action types listed above.
Focus on the last message and take it one step at a time.
Use the previous conversation steps only to aid understanding.

Your action list:
20 changes: 20 additions & 0 deletions .rasa/cache/tmpydlqtcg0/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"prompt": null,
"prompt_template": null,
"user_input": null,
"llm": {
"provider": "rasa",
"model": "rasa/cmd_gen_codellama_13b_calm_demo",
"api_base": "https://tutorial-llm.rasa.ai"
},
"flow_retrieval": {
"embeddings": {
"provider": "openai",
"model": "text-embedding-ada-002"
},
"num_flows": 20,
"turns_to_embed": 1,
"should_embed_slots": true,
"active": false
}
}
Empty file added actions/__init__.py
Empty file.
Binary file added actions/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added actions/__pycache__/actions.cpython-310.pyc
Binary file not shown.
28 changes: 28 additions & 0 deletions actions/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from rasa_sdk import Action
from rasa_sdk.executor import CollectingDispatcher
from transformers import AutoModelForCausalLM, AutoTokenizer

# Carica il modello e il tokenizer
tokenizer = AutoTokenizer.from_pretrained("OpenAssistant/oasst-sft-6-llama-30b")
model = AutoModelForCausalLM.from_pretrained("OpenAssistant/oasst-sft-6-llama-30b")

class ActionOpenAssistantResponse(Action):
def name(self) -> str:
return "action_openassistant_response"

def generate_response(self, prompt: str) -> str:
# Genera una risposta usando il modello OpenAssistant
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(inputs["input_ids"], max_length=100, num_return_sequences=1)
return tokenizer.decode(outputs[0], skip_special_tokens=True)

def run(self, dispatcher: CollectingDispatcher, tracker, domain):
# Ottieni l'ultimo messaggio dell'utente
user_message = tracker.latest_message.get("text")

# Genera una risposta
assistant_response = self.generate_response(user_message)

# Invia la risposta all'utente
dispatcher.utter_message(text=assistant_response)
return []
Loading