Skip to content

Commit

Permalink
Merge pull request #3132 from continuedev/nate/tool-use
Browse files Browse the repository at this point in the history
Nate/tool use
  • Loading branch information
sestinj authored Nov 30, 2024
2 parents 552555e + 40ae5be commit 4b3fe6a
Show file tree
Hide file tree
Showing 132 changed files with 3,653 additions and 1,462 deletions.
3 changes: 2 additions & 1 deletion .continueignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ docs/docs/languages
.idea/
.vscode/
.archive/
**/*.scm
**/*.scm
**/*.diff
1 change: 1 addition & 0 deletions core/autocomplete/generation/ListenableGenerator.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { jest } from "@jest/globals";

import { ListenableGenerator } from "./ListenableGenerator";

describe("ListenableGenerator", () => {
Expand Down
16 changes: 10 additions & 6 deletions core/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CustomCommand, SlashCommand, SlashCommandDescription } from "../";
import { stripImages } from "../llm/images";
import { renderTemplatedString } from "../promptFiles/v1/renderTemplatedString";
import { renderChatMessage } from "../util/messageContent";

import SlashCommands from "./slash";

Expand Down Expand Up @@ -29,7 +29,8 @@ export function slashFromCustomCommand(
const messages = [...history];
// Find the last chat message with this slash command and replace it with the user input
for (let i = messages.length - 1; i >= 0; i--) {
const { role, content } = messages[i];
const message = messages[i];
const { role, content } = message;
if (role !== "user") {
continue;
}
Expand All @@ -41,7 +42,7 @@ export function slashFromCustomCommand(
)
) {
messages[i] = {
...messages[i],
...message,
content: content.map((part) => {
return part.text?.startsWith(`/${customCommand.name}`)
? { ...part, text: promptUserInput }
Expand All @@ -53,13 +54,16 @@ export function slashFromCustomCommand(
typeof content === "string" &&
content.startsWith(`/${customCommand.name}`)
) {
messages[i] = { ...messages[i], content: promptUserInput };
messages[i] = { ...message, content: promptUserInput };
break;
}
}

for await (const chunk of llm.streamChat(messages, new AbortController().signal)) {
yield stripImages(chunk.content);
for await (const chunk of llm.streamChat(
messages,
new AbortController().signal,
)) {
yield renderChatMessage(chunk);
}
},
};
Expand Down
19 changes: 0 additions & 19 deletions core/commands/slash/comment.ts

This file was deleted.

4 changes: 2 additions & 2 deletions core/commands/slash/commit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SlashCommand } from "../../index.js";
import { stripImages } from "../../llm/images.js";
import { renderChatMessage } from "../../util/messageContent.js";

const CommitMessageCommand: SlashCommand = {
name: "commit",
Expand All @@ -18,7 +18,7 @@ const CommitMessageCommand: SlashCommand = {
[{ role: "user", content: prompt }],
new AbortController().signal,
)) {
yield stripImages(chunk.content);
yield renderChatMessage(chunk);
}
},
};
Expand Down
12 changes: 8 additions & 4 deletions core/commands/slash/draftIssue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChatMessage, SlashCommand } from "../../index.js";
import { stripImages } from "../../llm/images.js";
import { removeQuotesAndEscapes } from "../../util/index.js";
import { renderChatMessage } from "../../util/messageContent.js";

const PROMPT = (
input: string,
Expand Down Expand Up @@ -30,7 +30,8 @@ const DraftIssueCommand: SlashCommand = {
return;
}
let title = await llm.complete(
`Generate a title for the GitHub issue requested in this user input: '${input}'. Use no more than 20 words and output nothing other than the title. Do not surround it with quotes. The title is: `, new AbortController().signal,
`Generate a title for the GitHub issue requested in this user input: '${input}'. Use no more than 20 words and output nothing other than the title. Do not surround it with quotes. The title is: `,
new AbortController().signal,
{ maxTokens: 20 },
);

Expand All @@ -43,9 +44,12 @@ const DraftIssueCommand: SlashCommand = {
{ role: "user", content: PROMPT(input, title) },
];

for await (const chunk of llm.streamChat(messages, new AbortController().signal)) {
for await (const chunk of llm.streamChat(
messages,
new AbortController().signal,
)) {
body += chunk.content;
yield stripImages(chunk.content);
yield renderChatMessage(chunk);
}

const url = `${params.repositoryUrl}/issues/new?title=${encodeURIComponent(
Expand Down
Loading

0 comments on commit 4b3fe6a

Please sign in to comment.