enricorampazzo commited on
Commit
ce63277
·
1 Parent(s): 887083d

fixed the prompts so that they work as expected

Browse files
prompts/prompts_manager.py CHANGED
@@ -22,14 +22,14 @@ class PromptsManager:
22
  self.verification_prompt: str = verification_prompt
23
 
24
  def verify_user_input_prompt(self, user_prompt) -> str:
25
- return (f"Using only this information \n {user_prompt} \n answer the following questions, if the answer is not present or you are not sure about the answer just answer null. "
26
  f"Put each answer in a new line, keep the answer brief "
27
  f"and maintain the order in which the questions are asked. Do not add any preamble: "
28
  f"{self.verification_prompt}")
29
 
30
  def get_work_category(self, work_description: str) -> str:
31
- return (f"The work to do is {work_description}. Given the following categories {', '.join(self.work_categories.values())} "
32
- f"which ones are the most relevant? Only return the categories, separated by a semicolon")
33
 
34
  def ingest_user_answers(self, user_prompt: str) -> str:
35
  return f"Ingest the following information: {user_prompt}"
 
22
  self.verification_prompt: str = verification_prompt
23
 
24
  def verify_user_input_prompt(self, user_prompt) -> str:
25
+ return (f"Using only this information \n {user_prompt} \n answer the following questions, for each question that you cannot answer just answer 'null'. "
26
  f"Put each answer in a new line, keep the answer brief "
27
  f"and maintain the order in which the questions are asked. Do not add any preamble: "
28
  f"{self.verification_prompt}")
29
 
30
  def get_work_category(self, work_description: str) -> str:
31
+ return (f"The work to do is {work_description}: choose the most accurate categories among the following {', '.join(self.work_categories.values())} "
32
+ f"Only return the categories, separated by a semicolon")
33
 
34
  def ingest_user_answers(self, user_prompt: str) -> str:
35
  return f"Ingest the following information: {user_prompt}"
repository/ondemand.py CHANGED
@@ -16,15 +16,17 @@ class OndemandRepository(Repository):
16
  self.session_id = None
17
 
18
  def init(self):
 
 
 
19
  if not self.session_id:
20
  headers = {"apiKey": os.getenv("API_KEY")}
21
  session_body = {"pluginIds": [], "externalUserId": "virtualDAM", "modelConfigs":
22
- {"temperature": 0.2, "fulfillmentPrompt": self.system_message}
23
  }
24
  response = requests.post(self.session_url, headers=headers, json=session_body)
25
  response_data = response.json()
26
  self.session_id = response_data["data"]["id"]
27
-
28
  def get_model_roles(self) -> ModelRoles:
29
  return self.model_info.roles
30
 
@@ -32,6 +34,7 @@ class OndemandRepository(Repository):
32
  return self.model_info
33
 
34
  def send_prompt(self, prompt: str, add_to_history: bool = None) -> dict[str, str]:
 
35
  headers = {"apiKey": os.getenv("API_KEY")}
36
  body = {'endpointId': 'predefined-openai-gpt3.5turbo', 'query': prompt, 'pluginIds': [], 'responseMode': 'sync'}
37
  url = f'https://api.on-demand.io/chat/v1/sessions/{self.session_id}/query'
 
16
  self.session_id = None
17
 
18
  def init(self):
19
+ self._start_new_session_if_needed()
20
+
21
+ def _start_new_session_if_needed(self):
22
  if not self.session_id:
23
  headers = {"apiKey": os.getenv("API_KEY")}
24
  session_body = {"pluginIds": [], "externalUserId": "virtualDAM", "modelConfigs":
25
+ {"temperature": 0, "fulfillmentPrompt": self.system_message}
26
  }
27
  response = requests.post(self.session_url, headers=headers, json=session_body)
28
  response_data = response.json()
29
  self.session_id = response_data["data"]["id"]
 
30
  def get_model_roles(self) -> ModelRoles:
31
  return self.model_info.roles
32
 
 
34
  return self.model_info
35
 
36
  def send_prompt(self, prompt: str, add_to_history: bool = None) -> dict[str, str]:
37
+ self._start_new_session_if_needed()
38
  headers = {"apiKey": os.getenv("API_KEY")}
39
  body = {'endpointId': 'predefined-openai-gpt3.5turbo', 'query': prompt, 'pluginIds': [], 'responseMode': 'sync'}
40
  url = f'https://api.on-demand.io/chat/v1/sessions/{self.session_id}/query'