workflows:
# Workflow to decide where to route the user
decide_on_help_desk:
- name: "decide_help_desk_prompt"
type: "jinja"
config:
data_transformations:
messages:
jinja_template_str: "
{% for message in value %}
{% if message['role'] == 'user' %}
User: {{ message['content'] }}\n
{% else %}
Agent: {{ message['content'] }}\n
{% endif %}
{% endfor %}"
output_template:
jinja_template_str: "You must decide if the user conversation below should get routed to IT, HR, or Generic Chatbot, based on the *current state of the user* (e.g. their last message)
Conversation:
{{messages}}
Based on the above conversation please output 'IT', 'HR', or 'Other'.
"
inputs:
messages: messages
- name: "help_desk_decision_gen"
type: "generation"
config:
llm_model: "gpt-3.5-turbo"
max_tokens: 3
temperature: 0.2
inputs:
input_prompt: "decide_help_desk_prompt.output"
# HR Workflow
hr_workflow:
- name: "hr_instructions"
type: "jinja"
config:
output_template:
jinja_template_str: "
To figure out how many days off you have you should:
1. Calculate how many years you've been at the company
2. Multiply the number of years by 2
3. Add 10 to the result
"
inputs: {}
# IT Workflow
it_workflow:
- name: "it_instructions"
type: "jinja"
config:
output_template:
jinja_template_str: "
To reset your password you should:
1. Go to the company's password reset page
2. Enter your username
3. Follow the instructions on the page
"
inputs: {}
# Generic Chatbot Workflow
generic_chatbot_workflow:
- name: "generic_chatbot_instructions"
type: "jinja"
config:
output_template:
jinja_template_str: "No extra information"
inputs: {}
# Respond to the user with retrieved info
respond_to_user_given_context:
- name: "respond_to_user_template"
type: "jinja"
config:
data_transformations:
messages:
jinja_template_str: "
{% for message in value %}
{% if message['role'] == 'user' %}
User: {{ message['content'] }}\n
{% else %}
Agent: {{ message['content'] }}\n
{% endif %}
{% endfor %}"
output_template:
jinja_template_str: "
You are a helpful internal chatbot! You sometimes get access to information from HR, IT, etc. Sometimes you just have to think on the fly!
Here is some helpful information based on the conversation thus far:
{{retrieved_info}}
Based on the conversation, you should figure out what best to respond to the user with.
Conversation:
{{messages}}
Now, respond! The most important rule is that you *only* give one step at a time, the user will let you know once they've finished that step.
"
inputs:
messages: messages
retrieved_info: retrieved_info
- name: "respond_to_user"
type: "generation"
config:
llm_model: "gpt-3.5-turbo"
max_tokens: 100
temperature: 0.2
inputs:
input_prompt: "respond_to_user_template.output"
plan:
# Step 1: Decide where to route the help desk request
- workflow_name: "decide_on_help_desk"
workflow_inputs:
messages: messages
# Step 2: Run the appropriate workflow based on the decision
- branch: "get_help_desk_info"
conditional_workflows:
- condition: if
condition_input_var: "decide_on_help_desk.help_desk_decision_gen.output"
operator: "contains"
reference_var: "IT"
workflow_name: "it_workflow"
workflow_inputs: {}
- condition: elif
condition_input_var: "decide_on_help_desk.help_desk_decision_gen.output"
operator: "equals"
reference_var: "HR"
workflow_name: "hr_workflow"
workflow_inputs: {}
- condition: else
workflow_name: "generic_chatbot_workflow"
workflow_inputs: {}
merge_outputs:
retrieved_info:
- "it_workflow.it_instructions.output"
- "hr_workflow.hr_instructions.output"
- "generic_chatbot_workflow.generic_chatbot_instructions.output"
# Step 3: Generate the final response using retrieved information
- workflow_name: "respond_to_user_given_context"
workflow_inputs:
messages: messages
retrieved_info: "get_help_desk_info.retrieved_info.output"
final_output_nodes: ["respond_to_user_given_context.respond_to_user"]