fix(*): Ensure fallback data works correctly

This commit is contained in:
Josh Creek
2025-04-24 20:31:51 +01:00
parent b7a516cebb
commit cf907da7ba
2 changed files with 21 additions and 15 deletions
+15 -14
View File
@@ -23,10 +23,9 @@ if (!safeModel && !isTestEnv) {
throw new Error('AI_MODEL is not set'); throw new Error('AI_MODEL is not set');
} }
export const client = AIProjectsClient.fromConnectionString( export const client = !isTestEnv && safeConnString
safeConnString!, ? AIProjectsClient.fromConnectionString(safeConnString, new DefaultAzureCredential())
new DefaultAzureCredential() : undefined;
);
// const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([]); // const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([]);
@@ -71,13 +70,15 @@ export const toolResources = allTools.reduce<Record<string, any>>((map, t) => {
return map; return map;
}, {}); }, {});
export const agent = await client.agents.createAgent(AI_MODEL, { export const agent = client
name: `assessment-feedback-agent`, ? await client.agents.createAgent(AI_MODEL, {
instructions, name: `assessment-feedback-agent`,
temperature: 0.5, instructions,
tools, temperature: 0.5,
toolResources, tools,
requestOptions: { toolResources,
headers: { 'x-ms-enable-preview': 'true' } requestOptions: {
} headers: { 'x-ms-enable-preview': 'true' }
}); }
})
: undefined;
+6 -1
View File
@@ -145,7 +145,12 @@ export async function gradeSubmissionWithAgent(
task: string, task: string,
roomId: string roomId: string
): Promise<OpenAIResponse> { ): Promise<OpenAIResponse> {
if (!client || !agent) { if (!client) {
// In test/CI mode, return fallback data
return fallbackGrade(submission, task);
}
if (!agent) {
throw new Error('Agent not available'); throw new Error('Agent not available');
} }