fix(all): LLM JSON.

This commit is contained in:
me@rodrigorodriguez.com 2024-10-28 13:48:13 -03:00
parent cada29fd6d
commit 6a5d6b37c2

View file

@ -400,16 +400,14 @@ export class ChatServices {
const jsonInformation = ` const jsonInformation = `
Let me help improve that prompt to be more concise and clearer:
RESPONSE FORMAT: Return only a single valid JSON object with no surrounding text. Structure: RESPONSE FORMAT: Return only a single valid JSON object with no surrounding text. Structure:
{{"text": "Complete response as a single string, using \\n for all line breaks, \n1. bullets and; \n2.lists.", "sources": [{{"file": "filename", "page": number}}]}} {{"text": "Complete response as a single string, using \\n for all line breaks, \n1. bullets and; \n2.lists.", "sources": [{{"file": "filename", "page": number}}]}}
CRITICAL REQUIREMENTS: CRITICAL REQUIREMENTS:
1. Only valid JSON, no text/formatting before/after 1. Only valid JSON, no text/formatting before/after (VERY VERY IMPORTANT)
2. No actual line breaks - encode ALL as \n 2. No actual line breaks - encode ALL as \n
3. Bullets/lists formatted as "1. " or "• " with \n 3. Bullets/lists formatted as "1. " or "• " with \n
4. Sources cite only content pages 4. Sources cite only content pages inside sources JSON tag.
5. Text field contains complete response 5. Text field contains complete response
6. Valid according to RFC 8259 6. Valid according to RFC 8259
7. No quotes/markdown around JSON 7. No quotes/markdown around JSON
@ -418,7 +416,7 @@ export class ChatServices {
"1. First point\\n2. Second point\\n" or "• First\\n• Second\\n" "1. First point\\n2. Second point\\n" or "• First\\n• Second\\n"
VALIDATION: Confirm output contains: VALIDATION: Confirm output contains:
- Single JSON object - Single JSON object (no free text)
- No line breaks except \n in strings - No line breaks except \n in strings
- No surrounding text - No surrounding text
- Valid source pages - Valid source pages