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
+7 -6
View File
@@ -23,10 +23,9 @@ if (!safeModel && !isTestEnv) {
throw new Error('AI_MODEL is not set');
}
export const client = AIProjectsClient.fromConnectionString(
safeConnString!,
new DefaultAzureCredential()
);
export const client = !isTestEnv && safeConnString
? AIProjectsClient.fromConnectionString(safeConnString, new DefaultAzureCredential())
: undefined;
// const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([]);
@@ -71,7 +70,8 @@ export const toolResources = allTools.reduce<Record<string, any>>((map, t) => {
return map;
}, {});
export const agent = await client.agents.createAgent(AI_MODEL, {
export const agent = client
? await client.agents.createAgent(AI_MODEL, {
name: `assessment-feedback-agent`,
instructions,
temperature: 0.5,
@@ -80,4 +80,5 @@ export const agent = await client.agents.createAgent(AI_MODEL, {
requestOptions: {
headers: { 'x-ms-enable-preview': 'true' }
}
});
})
: undefined;
+6 -1
View File
@@ -145,7 +145,12 @@ export async function gradeSubmissionWithAgent(
task: string,
roomId: string
): 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');
}