mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
refactor: Change format requested from AI
Refs: OPS-12
This commit is contained in:
parent
e96ab55378
commit
62e964b800
1 changed files with 7 additions and 16 deletions
|
|
@ -20,24 +20,14 @@ HAIKU DEFINITION:
|
||||||
- Must incorporate the subject(s) from user input
|
- Must incorporate the subject(s) from user input
|
||||||
|
|
||||||
OUTPUT RULES:
|
OUTPUT RULES:
|
||||||
1. ONLY respond with a valid JSON object in this exact format:
|
Put every line of the poem on a new line
|
||||||
{
|
|
||||||
"line1": "First line of haiku",
|
|
||||||
"line2": "Second line of haiku",
|
|
||||||
"line3": "Third line of haiku"
|
|
||||||
}
|
|
||||||
|
|
||||||
2. Do NOT include:
|
2. Do NOT include:
|
||||||
- Any explanations
|
- Any explanations
|
||||||
- Any markdown formatting (like ```json or ```)
|
- Any markdown formatting (like ```json or ```)
|
||||||
- Any additional text before or after the JSON
|
- Any additional text before or after the JSON
|
||||||
- Any line breaks within the JSON structure
|
- Any line breaks within the JSON structure
|
||||||
|
- Any special characters
|
||||||
3. Before submitting, verify:
|
|
||||||
- The JSON uses double quotes (not single quotes)
|
|
||||||
- All property names are lowercase and exactly as shown above
|
|
||||||
- There are no trailing commas
|
|
||||||
- The JSON is properly formatted
|
|
||||||
|
|
||||||
IMPORTANT: The output will be consumed by a web application that requires
|
IMPORTANT: The output will be consumed by a web application that requires
|
||||||
EXACT FORMAT compliance. Any deviation will cause the application to break.
|
EXACT FORMAT compliance. Any deviation will cause the application to break.
|
||||||
|
|
@ -68,12 +58,13 @@ class Haiku:
|
||||||
try:
|
try:
|
||||||
r = requests.post(url=AI_BASE_URL + AI_GEN_ENDPOINT,
|
r = requests.post(url=AI_BASE_URL + AI_GEN_ENDPOINT,
|
||||||
json=ai_gen_request)
|
json=ai_gen_request)
|
||||||
ai_response = json.loads(r.json()["response"])
|
ai_response = str(r.json()["response"])
|
||||||
|
lines = ai_response.split("\n")
|
||||||
haiku = Haiku(
|
haiku = Haiku(
|
||||||
[
|
[
|
||||||
ai_response["line1"],
|
lines[0],
|
||||||
ai_response["line2"],
|
lines[1],
|
||||||
ai_response["line3"]
|
lines[2]
|
||||||
])
|
])
|
||||||
break
|
break
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue