mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-03 12:22:38 +02:00
copilot: fixed response
This commit is contained in:
parent
a7975ff4ff
commit
be3eb610a0
2 changed files with 7 additions and 2 deletions
|
|
@ -480,7 +480,7 @@ You are responsible for providing delivery information to the user.
|
||||||
output format:
|
output format:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"response": "<new agent instructions with relevant changes>"
|
"agent_instructions": "<new agent instructions with relevant changes>"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -200,10 +200,15 @@ export async function getCopilotAgentInstructions(
|
||||||
|
|
||||||
// parse and return response
|
// parse and return response
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
console.log(`copilot response`, JSON.stringify(json, null, 2));
|
console.log(`copilot response`, JSON.stringify(json, null, 2));
|
||||||
let copilotResponse: z.infer<typeof CopilotAPIResponse>;
|
let copilotResponse: z.infer<typeof CopilotAPIResponse>;
|
||||||
|
let agent_instructions: string;
|
||||||
try {
|
try {
|
||||||
copilotResponse = CopilotAPIResponse.parse(json);
|
copilotResponse = CopilotAPIResponse.parse(json);
|
||||||
|
const content = json.response.replace(/^```json\n/, '').replace(/\n```$/, '');
|
||||||
|
agent_instructions = JSON.parse(content).agent_instructions;
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to parse copilot response', e);
|
console.error('Failed to parse copilot response', e);
|
||||||
throw new 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 response
|
||||||
return copilotResponse.response;
|
return agent_instructions;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue