mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-03 19:25:19 +02:00
copilot: fixed response
This commit is contained in:
parent
a7975ff4ff
commit
be3eb610a0
2 changed files with 7 additions and 2 deletions
|
|
@ -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<typeof CopilotAPIResponse>;
|
||||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue