ofermend commited on
Commit
0d707b6
1 Parent(s): 2f3e659

escaping quotes to prevent failure

Browse files
Files changed (1) hide show
  1. query.py +10 -8
query.py CHANGED
@@ -21,17 +21,19 @@ class VectaraQuery():
21
  'customer_id': self.customer_id, 'corpus_id': self.corpus_id, 'lexical_interpolation_config': {'lambda': 0.025}
22
  }]
23
 
 
24
  prompt = f'''
25
  [
26
  {{
27
  "role": "system",
28
  "content": "You are a professional debate bot.
29
  You specialize in the {style} debate style.
30
- You are provided with search results related to {topic}
31
- and respond to the previous arugments made so far. Be sure to provide a thoughtful and convincing reply.
32
- Never mention search results explicitly in your response.
33
- Do not base your response on information or knowledge that is not in the search results.
34
- Respond while demonstrating respect to the other party and the topic. Limit your responses to not more than 2 paragraphs."
 
35
  }},
36
  {{
37
  "role": "user",
@@ -43,8 +45,8 @@ class VectaraQuery():
43
  }},
44
  {{
45
  "role": "user",
46
- "content": "provide a convincing reply {role} {topic} in response to the last argument '{user_response}.
47
- Consider the search results as relevant information with which to form your response.
48
  Use the {style} debate style to make your argument.
49
  Do not repeat earlier arguments and make sure your new response is coherent with the previous arguments."
50
  }}
@@ -54,7 +56,7 @@ class VectaraQuery():
54
  return {
55
  'query': [
56
  {
57
- 'query': "how would you respond?",
58
  'start': 0,
59
  'numResults': 50,
60
  'corpusKey': corpora_key_list,
 
21
  'customer_id': self.customer_id, 'corpus_id': self.corpus_id, 'lexical_interpolation_config': {'lambda': 0.025}
22
  }]
23
 
24
+ user_response = user_response.replace('"', '\\"') # Escape double quotes
25
  prompt = f'''
26
  [
27
  {{
28
  "role": "system",
29
  "content": "You are a professional debate bot.
30
  You specialize in the {style} debate style.
31
+ You are provided with search results related to {topic}.
32
+ Follow these INSTRUCTIONS carefully:
33
+ 1. Provide a thoughtful and convincing reply.
34
+ 2. Do not base your response on information or knowledge that is not in the search results.
35
+ 3. Respond while demonstrating respect to the other party and the topic.
36
+ 4. Limit your responses to not more than 2 paragraphs."
37
  }},
38
  {{
39
  "role": "user",
 
45
  }},
46
  {{
47
  "role": "user",
48
+ "content": "provide a convincing reply {role} {topic}, in response to the last argument: '{user_response}'.
49
+ Consider the search results as relevant information with which to form your response, but do not mention the results in your response.
50
  Use the {style} debate style to make your argument.
51
  Do not repeat earlier arguments and make sure your new response is coherent with the previous arguments."
52
  }}
 
56
  return {
57
  'query': [
58
  {
59
+ 'query': f"{role} {topic}, how would you respond?",
60
  'start': 0,
61
  'numResults': 50,
62
  'corpusKey': corpora_key_list,