Skip to content

Commit 0bda26d

Browse files
authoredOct 24, 2024
Merge pull request #19 from copilot-extensions/sgoedecke/work-around-nil-refs-and-add-400-logging
2 parents 4067c19 + 2376887 commit 0bda26d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed
 

‎src/functions/execute-model.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ Example Queries (IMPORTANT: Phrasing doesn't have to match):
5151
): Promise<RunnerResponse> {
5252
// Check if the user included any code references in their last message
5353
const lastMessage = messages[messages.length - 1];
54-
const importantRefs = lastMessage.copilot_references.filter(
55-
(ref) => ref.type === "client.selection" || ref.type === "client.file"
56-
);
54+
let importantRefs: Reference[] = [];
55+
if (lastMessage.copilot_references) {
56+
importantRefs = lastMessage.copilot_references.filter((ref) => ref.type === "client.selection" || ref.type === "client.file");
57+
}
5758

5859
const content = [
5960
`The user has chosen to use the model named ${args.model}.`,

‎src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ const server = createServer(async (request, response) => {
224224
response.end();
225225
} catch (err) {
226226
console.error(err);
227+
228+
if ((err as any).response && (err as any).response.status === 400) {
229+
console.error('Error 400:', (err as any).response.data);
230+
}
231+
227232
response.statusCode = 500
228233
response.write("data: Something went wrong\n\n")
229234
response.end()

0 commit comments

Comments
 (0)
Failed to load comments.