Skip to content

Commit

Permalink
Merge pull request #19 from copilot-extensions/sgoedecke/work-around-…
Browse files Browse the repository at this point in the history
…nil-refs-and-add-400-logging
  • Loading branch information
sgoedecke authored Oct 24, 2024
2 parents 4067c19 + 2376887 commit 0bda26d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/functions/execute-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ Example Queries (IMPORTANT: Phrasing doesn't have to match):
): Promise<RunnerResponse> {
// Check if the user included any code references in their last message
const lastMessage = messages[messages.length - 1];
const importantRefs = lastMessage.copilot_references.filter(
(ref) => ref.type === "client.selection" || ref.type === "client.file"
);
let importantRefs: Reference[] = [];
if (lastMessage.copilot_references) {
importantRefs = lastMessage.copilot_references.filter((ref) => ref.type === "client.selection" || ref.type === "client.file");
}

const content = [
`The user has chosen to use the model named ${args.model}.`,
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ const server = createServer(async (request, response) => {
response.end();
} catch (err) {
console.error(err);

if ((err as any).response && (err as any).response.status === 400) {
console.error('Error 400:', (err as any).response.data);
}

response.statusCode = 500
response.write("data: Something went wrong\n\n")
response.end()
Expand Down

0 comments on commit 0bda26d

Please sign in to comment.