mrwadams commited on
Commit
781082b
β€’
1 Parent(s): 0fcb26c

Improve user feedback handling. Update system prompt for Technical Writer

Browse files
Files changed (1) hide show
  1. app.py +33 -10
app.py CHANGED
@@ -93,20 +93,37 @@ class ChainlitUserProxyAgent(UserProxyAgent):
93
  cl.AskActionMessage,
94
  content="Continue or provide feedback?",
95
  actions=[
96
- cl.Action( name="continue", value="continue", label="βœ… Continue" ),
97
- cl.Action( name="feedback",value="feedback", label="πŸ’¬ Provide feedback"),
98
- cl.Action( name="exit",value="exit", label="πŸ”š Exit Conversation" )
99
  ],
100
  )
101
  )
102
  if res.get("value") == "continue":
103
  return ""
104
- if res.get("value") == "exit":
 
 
 
 
 
 
 
 
 
 
105
  return "exit"
106
-
107
- reply = cl.run_sync(ask_helper(cl.AskUserMessage, content=prompt, timeout=60))
108
-
109
- return reply["content"].strip()
 
 
 
 
 
 
 
110
 
111
  def send(
112
  self,
@@ -166,8 +183,14 @@ async def start():
166
  writer = ChainlitAssistantAgent(
167
  name="Technical_Writer", llm_config=llm_config,
168
  system_message="""As the Technical Writer, your primary responsibility is creating highly detailed and informative information security policies aligned with recognised industry best practices.
 
169
  Your focus is on producing well-structured documents written in a formal and professional tone, incorporating appropriate headings, subheadings, and bullet points to aid readability.
170
- Ensure that the generated policies are exhaustive yet concise while maintaining clarity."""
 
 
 
 
 
171
  )
172
  user_proxy = ChainlitUserProxyAgent(
173
  name="User_Proxy",
@@ -176,7 +199,7 @@ async def start():
176
  # max_consecutive_auto_reply=3,
177
  # is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
178
  code_execution_config=False,
179
- system_message="""User Proxy. Provides feedback on the policy document and guides the team through the process."""
180
  )
181
 
182
  cl.user_session.set(USER_PROXY_NAME, user_proxy)
 
93
  cl.AskActionMessage,
94
  content="Continue or provide feedback?",
95
  actions=[
96
+ cl.Action(name="continue", value="continue", label="βœ… Continue"),
97
+ cl.Action(name="feedback", value="feedback", label="πŸ’¬ Provide feedback"),
98
+ cl.Action(name="exit", value="exit", label="πŸ”š Exit Conversation")
99
  ],
100
  )
101
  )
102
  if res.get("value") == "continue":
103
  return ""
104
+ elif res.get("value") == "feedback":
105
+ # Prompt the user for feedback
106
+ feedback_prompt = "Please provide your feedback:"
107
+ feedback_reply = cl.run_sync(ask_helper(cl.AskUserMessage, content=feedback_prompt, timeout=60))
108
+ if "content" in feedback_reply:
109
+ # Return the feedback content to be used as the next message
110
+ return feedback_reply["content"].strip()
111
+ else:
112
+ print("No feedback provided.")
113
+ return ""
114
+ elif res.get("value") == "exit":
115
  return "exit"
116
+ else:
117
+ # Handle other cases or errors
118
+ return ""
119
+ else:
120
+ reply = cl.run_sync(ask_helper(cl.AskUserMessage, content=prompt, timeout=60))
121
+ if "content" in reply:
122
+ return reply["content"].strip()
123
+ else:
124
+ # Handle the absence of 'content' key gracefully
125
+ print("No content received. Reply was:", reply)
126
+ return ""
127
 
128
  def send(
129
  self,
 
183
  writer = ChainlitAssistantAgent(
184
  name="Technical_Writer", llm_config=llm_config,
185
  system_message="""As the Technical Writer, your primary responsibility is creating highly detailed and informative information security policies aligned with recognised industry best practices.
186
+
187
  Your focus is on producing well-structured documents written in a formal and professional tone, incorporating appropriate headings, subheadings, and bullet points to aid readability.
188
+
189
+ Ensure that the generated policies are exhaustive yet concise while maintaining clarity.
190
+
191
+ Effective policies are at least three pages long and contain at least five bullet points in each policy detail section. If you meet these requirements you will receive a performance bonus of $500.
192
+
193
+ When updating the policy document in response to the Reviewer's feedback, ensure that you provide the full contents of the policy document. DO NOT reply with just the changes made."""
194
  )
195
  user_proxy = ChainlitUserProxyAgent(
196
  name="User_Proxy",
 
199
  # max_consecutive_auto_reply=3,
200
  # is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
201
  code_execution_config=False,
202
+ system_message="""User Proxy. Provides feedback on the policy document and guides the team through the process. Ask if the user wants to provide feedback after the Reviewer's evaluation."""
203
  )
204
 
205
  cl.user_session.set(USER_PROXY_NAME, user_proxy)