diff --git a/apps/copilot/copilot.py b/apps/copilot/copilot.py index 573d5236..2266cfe8 100644 --- a/apps/copilot/copilot.py +++ b/apps/copilot/copilot.py @@ -480,7 +480,7 @@ You are responsible for providing delivery information to the user. output format: ```json { - "response": "" + "agent_instructions": "" } ``` """ diff --git a/apps/rowboat/app/actions/copilot_actions.ts b/apps/rowboat/app/actions/copilot_actions.ts index a093330a..d677d599 100644 --- a/apps/rowboat/app/actions/copilot_actions.ts +++ b/apps/rowboat/app/actions/copilot_actions.ts @@ -200,10 +200,15 @@ export async function getCopilotAgentInstructions( // parse and return response const json = await response.json(); + console.log(`copilot response`, JSON.stringify(json, null, 2)); let copilotResponse: z.infer; + let agent_instructions: string; try { copilotResponse = CopilotAPIResponse.parse(json); + const content = json.response.replace(/^```json\n/, '').replace(/\n```$/, ''); + agent_instructions = JSON.parse(content).agent_instructions; + } catch (e) { console.error('Failed to parse copilot response', e); throw new Error(`Failed to parse copilot response: ${e}`); @@ -213,5 +218,5 @@ export async function getCopilotAgentInstructions( } // return response - return copilotResponse.response; + return agent_instructions; } \ No newline at end of file