yaleh commited on
Commit
f3f8bb6
·
1 Parent(s): ce61883

Updated prompt analyzer.

Browse files
Files changed (2) hide show
  1. config.yml +23 -20
  2. meta_prompt/meta_prompt.py +14 -3
config.yml CHANGED
@@ -312,35 +312,38 @@ prompt_templates:
312
  prompt_analyzer:
313
  - role: system
314
  message: |
315
- You are a text comparing program. You compare the following output texts, analysis the System Message and provide a detailed analysis according to [`Acceptance Criteria`]. Then you decide whether [`Actual Output`] is acceptable.
316
 
317
- Provide your analysis in the following format:
 
 
 
318
 
319
- ```
320
- - Acceptable Differences: [List acceptable differences succinctly]
321
- - Unacceptable Differences: [List unacceptable differences succinctly]
322
- - Accept: [Yes/No]
323
- ```
324
 
325
- * Compare Expected Output and Actual Output with the guidance of Accept Criteria.
326
- * Only set 'Accept' to 'Yes', if Accept Criteria are all met. Otherwise, set 'Accept' to 'No'.
327
- * List only the acceptable differences according to Accept Criteria in 'acceptable Differences' section.
328
- * List only the unacceptable differences according to Accept Criteria in 'Unacceptable Differences' section.
 
 
 
 
 
 
 
 
 
329
 
330
  # Acceptance Criteria
331
 
332
- Compared with Expected Output [EO]:
333
- ```
334
  {acceptance_criteria}
335
- ```
336
  - role: human
337
  message: |
338
- # System Message
339
-
340
- ```
341
- {system_message}
342
- ```
343
-
344
  # Expected Output
345
 
346
  ```
 
312
  prompt_analyzer:
313
  - role: system
314
  message: |
315
+ **TASK:** Compare the Expected Output with the Actual Output according to the Acceptance Criteria. Provide a JSON output with your analysis.
316
 
317
+ **Requirements:**
318
+ - Compare Expected and Actual Outputs strictly following the Acceptance Criteria.
319
+ - Set `Accept` to "Yes" only if all criteria are met; otherwise, set it to "No."
320
+ - List acceptable and unacceptable differences based on the criteria.
321
 
322
+ **Output Format:** JSON with:
323
+ - `Accept: (Yes/No)`
324
+ - `Acceptable Differences: []`
325
+ - `Unacceptable Differences: []`
 
326
 
327
+ **Example Output:**
328
+ ```json
329
+ {{
330
+ "Accept": "No",
331
+ "Acceptable Differences": [
332
+ "Spelling variations: 'colour' vs 'color'"
333
+ ],
334
+ "Unacceptable Differences": [
335
+ "Missing section: 'Conclusion'",
336
+ "Incorrect date format: '2023/10/12' vs '12-10-2023'"
337
+ ]
338
+ }}
339
+ ```
340
 
341
  # Acceptance Criteria
342
 
 
 
343
  {acceptance_criteria}
344
+
345
  - role: human
346
  message: |
 
 
 
 
 
 
347
  # Expected Output
348
 
349
  ```
meta_prompt/meta_prompt.py CHANGED
@@ -464,7 +464,10 @@ class MetaPromptGraph:
464
  'message': message.content
465
  })
466
 
467
- response = self.llms[NODE_OUTPUT_HISTORY_ANALYZER].invoke(prompt)
 
 
 
468
  logger.debug({
469
  'node': NODE_OUTPUT_HISTORY_ANALYZER,
470
  'action': 'response',
@@ -529,7 +532,8 @@ class MetaPromptGraph:
529
  'message': message.content
530
  })
531
 
532
- response = self.llms[NODE_PROMPT_ANALYZER].invoke(prompt)
 
533
  logger.debug({
534
  'node': NODE_PROMPT_ANALYZER,
535
  'action': 'response',
@@ -537,9 +541,16 @@ class MetaPromptGraph:
537
  'message': response.content
538
  })
539
 
 
 
 
 
 
 
 
540
  result_dict = {
541
  "analysis": response.content,
542
- "accepted": "Accept: Yes" in response.content
543
  }
544
  logger.debug("Accepted: %s", result_dict["accepted"])
545
 
 
464
  'message': message.content
465
  })
466
 
467
+
468
+ json_llm = self.llms[NODE_OUTPUT_HISTORY_ANALYZER].bind(response_format={"type": "json_object"})
469
+ response = json_llm.invoke(prompt)
470
+
471
  logger.debug({
472
  'node': NODE_OUTPUT_HISTORY_ANALYZER,
473
  'action': 'response',
 
532
  'message': message.content
533
  })
534
 
535
+ json_llm = self.llms[NODE_OUTPUT_HISTORY_ANALYZER].bind(response_format={"type": "json_object"})
536
+ response = json_llm.invoke(prompt)
537
  logger.debug({
538
  'node': NODE_PROMPT_ANALYZER,
539
  'action': 'response',
 
541
  'message': response.content
542
  })
543
 
544
+ response_content = response.content.strip()
545
+ if response_content.startswith('```json') and response_content.endswith('```'):
546
+ response_content = response_content[7:-3].strip()
547
+ elif response_content.startswith('```') and response_content.endswith('```'):
548
+ response_content = response_content[3:-3].strip()
549
+ analysis_dict = json.loads(response_content)
550
+
551
  result_dict = {
552
  "analysis": response.content,
553
+ "accepted": analysis_dict.get("Accept") == "Yes"
554
  }
555
  logger.debug("Accepted: %s", result_dict["accepted"])
556