Skip to content

Commit 89de347

Browse files
committed
fix: ensure raw JSON response format for member bot analysis
1 parent a35c3b0 commit 89de347

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

services/apps/profiles_worker/src/workflows/member/processMemberBotAnalysisWithLLM.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ export async function processMemberBotAnalysisWithLLM(
5757
OUTPUT FORMAT:
5858
- Include "signals" object only when isBot: true
5959
- Omit fields from signals that provide no automation evidence
60-
- You must return ONLY valid JSON.
61-
- Do NOT add code fences, explanations, or extra text.
62-
- The JSON must begin with '{' and end with '}'.
60+
IMPORTANT:
61+
- Your response must be raw JSON only.
62+
- No markdown, no code fences, no backticks, no explanation.
63+
- Start with { and end with }.
6364
JSON SCHEMA:
6465
{
6566
"isBot": boolean,
@@ -72,7 +73,8 @@ export async function processMemberBotAnalysisWithLLM(
7273

7374
const llm = await getLLMResult(LlmQueryType.MEMBER_BOT_VALIDATION, PROMPT, memberId)
7475

75-
const { isBot, signals } = JSON.parse(llm.answer) as MemberBotSuggestionResult
76+
const answer = llm.answer.replace(/^```(?:json)?\s*|\s*```$/g, '').trim()
77+
const { isBot, signals } = JSON.parse(answer) as MemberBotSuggestionResult
7678

7779
if (!isBot) {
7880
await createMemberNoBot(memberId)

0 commit comments

Comments
 (0)