App_Simulator / prompts.py
jjz5463's picture
buttons update
92e05c4
raw
history blame
5.15 kB
def get_system_prompt(app_name, system_data, task, user_data, current_page, last_page, actions, user_state, page_info, page_linkage):
system_prompt = f"""
You are a text-based {app_name}-like app simulator game.
The {app_name} app contains the following system data: {system_data}.
You are interacting with a user whose task is: {task}.
User's data: {user_data}.
The user's last page was {last_page}, and they have taken the following actions: {actions}.
After performing the most recent action, the user is now on the {current_page} page.
Current user state: {user_state}.
Details and buttons on the current page:
{page_info}
Current page links to these pages:
{page_linkage}
Each button on the page has a `name` and an `action_type`.
### Instruction Format:
<If `actions` is non-empty: "You have successfully performed actions[-1]"> z
<If current_page == log in & user_state['logged_in'] == False: You need to log in first. Your credentials are: Username: user_data['credentials']['user_id'] Password: user_data['credentials']['password']>
<If current_page == log in & user_state['logged_in'] == True: You have successfully logged in as user_data['credentials']['user_id']>
You are currently on the **{current_page}** page.
<Display static information to users based on system data and user data on the current page (e.g., display search results)>
You have the following options:
1. option 1: action type
2. option 2: action type
3. option 3: action type
4. option 4: action type
<If any linked page does not have button links to it, add the button.>
5. Back to last page: click
6. Back to Home page: click
7. <If user_state['logged_in'] == False, display Log In: click to take user to log in page>
8. Do nothing: noop
Each button is in the format: `number. button name: action_type`.
Please provide your choice in the format: `action_type(button name)`.
If you have a query, use the format: `type(button name, query)`.
Please provide only one choice per turn.
### **Rules**:
1. Display all available options from the buttons on the page.
2. Remain robotic and emotionless. Avoid offering any advice or opinions to the user.
3. Ensure there is always a button to navigate back to the **{last_page}** and a button to go to the **Home page**.
4. Ensure there is always a button that allow user to do nothing.
5. Ensure the action type is a single word, such as ‘type’ or ‘click.’ If the action type is not a single word, convert it to a single word. For example, type(SUMMER, apply) should be transformed to type.
6. Group similar action types under ‘type’ and display them as ‘type’ (e.g., display ‘input’ or ‘search’ as ‘type’).
7. Mimic the real {app_name} scenario as much as possible.
"""
return system_prompt
def get_user_state_update_prompt(user_input, current_page, task, solution, user_state, sitemap):
structure = """
{
'current_page': 'Home',
'task_completed': False,
'back': False
}
"""
update_prompt = f"""
You will now update the user state.
The user takes the action '{user_input}' on the {current_page} page. Determine which page the user will move to next.
The next page must from the sitemap: {sitemap}
Recall the user's task: {task}. Solution to the user's task: {solution}.
Update the `user_state` dictionary based on the user's last action:
Current user_state: {user_state}.
### Instructions:
1. If the 'current_page' has changed, update it to a valid page from the sitemap.
2. If the task is completed, update 'task_completed' to `True`. Otherwise, leave it as `False`.
3. If no updates are needed, return the `user_state` exactly as provided, without any changes.
### Important Notes:
- Ensure 'current_page' and 'task_completed' are always present as keys in the returned dictionary.
- If the user go back a page from current page, set 'back' to `True`. Otherwise, it should remain `False`.
- Return only the updated dictionary, without additional text, explanations, or wrapping.
### Output Format:
1. Start with "REASON": Explain which fields in `user_state` need to be updated and why.
2. End with "UPDATED": Provide only the updated `user_state` dictionary. Follow the input user_state schema structure exactly without modifying its organization. Do not include explanations or any additional text after updated user state.
"""
return update_prompt
def get_agent_prompt(app_name, task, conversation):
agent_prompt = f"""
Imagine you are an agent navigate through the {app_name} environment.
Your overarching task is: {task}. You may have done some part of the task, or none at all.
You will have access to all of your previous actions in the environment, as well as the last message from the assistant giving the current state of the environment.
The last message from the assistant was: {conversation[-1]['content']}
Respond first with a brief "Plan" which suggests what steps you are going to take to accomplish the task, and what your immediate.
Then generate an "Action" which is the immediate next step you can take.
"""
return agent_prompt