Spaces:
Running
Running
Updated prompt analyzer.
Browse files- config.yml +23 -20
- 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 |
-
|
316 |
|
317 |
-
|
|
|
|
|
|
|
318 |
|
319 |
-
|
320 |
-
-
|
321 |
-
-
|
322 |
-
-
|
323 |
-
```
|
324 |
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
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 |
-
|
|
|
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
|
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 |
|