Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add prompt snippets support #234220

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
156e119
[prompt snippets]: working on recursive file references
legomushroom Nov 5, 2024
109215c
[prompt snippets]: working on file contents codec
legomushroom Nov 5, 2024
04fa76d
[prompt snippets]: implement the `LinesCodecDecoder`
legomushroom Nov 6, 2024
b668d18
[prompt snippets]: working on the `SimpleTokensCodecDecoder`
legomushroom Nov 6, 2024
e88c220
[prompt snippets]: implement first version of `PromptSyntaxCodec`
legomushroom Nov 6, 2024
b7b9fe1
[prompt snippets]: add `Range` attributes to all the tokens
legomushroom Nov 7, 2024
85b7a8f
[prompt snippets]: refactoring components to standalone files
legomushroom Nov 7, 2024
70b2340
[prompt snippets]: move out components to separate files, working on …
legomushroom Nov 7, 2024
a11647f
[prompt snippets]: add the first unit test for `LinesDecoder`
legomushroom Nov 8, 2024
10bfe39
[prompt snippets]: add first unit test for the `SimpleDecoder`
legomushroom Nov 8, 2024
4bce992
[prompt snippets]: refactor `SimpleDecoder` logic
legomushroom Nov 8, 2024
7b993db
[prompt snippets]: make `SimpleDecoder` handle `\t` characters and im…
legomushroom Nov 8, 2024
4b23ffc
[prompt snippets]: add unit tests for the `ChatbotPromptCodec` codec
legomushroom Nov 8, 2024
e264037
[prompt snippets]: add unit test for the `ChatbotPromptReference`
legomushroom Nov 9, 2024
ba0c55e
[prompt snippets]: working on enhancing prompt context
legomushroom Nov 11, 2024
716049e
[prompt snippets]: enahnce working set file references on submit
legomushroom Nov 11, 2024
9b20b24
[prompt snippets]: cleanup
legomushroom Nov 11, 2024
0e1c18b
[prompt snippets]: implement automatic references resolution on file …
legomushroom Nov 12, 2024
73840d5
[prompt snippets]: implement prompt snippets for implicit context files
legomushroom Nov 12, 2024
a0bc737
[prompt snippets]: improve implicit context file rendering
legomushroom Nov 13, 2024
c2de3bc
[prompt snippets]: remove redundant `ChatReference` class
legomushroom Nov 13, 2024
3dba461
[prompt snippets]: `PromptReference` can now subscribe to filesystem …
legomushroom Nov 13, 2024
68092a6
[prompt snippets]: make `LinesDecoder` to also emit `NewLine` tokens,…
legomushroom Nov 13, 2024
059cb73
[prompt snippets]: resolve nested references for dynamic variables an…
legomushroom Nov 14, 2024
c7e526d
[prompt snippets]: add nested file references to implicit context of …
legomushroom Nov 14, 2024
02bc33d
[prompt snippets]: variable hover label now includes nested file refe…
legomushroom Nov 14, 2024
4834008
[prompt snippets]: add the `TestDecoder` and `TestLinesDecoder` reusa…
legomushroom Nov 14, 2024
417cb3e
[prompt snippets]: add unit tests for `ChatbotPromptDecoder` decoder
legomushroom Nov 15, 2024
d543f4f
[prompt snippets]: refactor decoders to eliminate static type hacks
legomushroom Nov 15, 2024
26ab1b9
[prompt snippets]: improve `BaseDecoder` logic and docs
legomushroom Nov 15, 2024
e616c9d
[prompt snippets]: add unit tests for the new reduce-less logic of th…
legomushroom Nov 15, 2024
7126ffb
[prompt snippets]: improve doc comments, finish the basic unit test f…
legomushroom Nov 15, 2024
f904f50
[prompt snippets]: finish the main unit test for the `PromptFileRefer…
legomushroom Nov 15, 2024
dadf968
[prompt snippets]: make the `PromptFileReference` class ininite-refer…
legomushroom Nov 16, 2024
30e6e6a
[prompt snippets]: cleanup
legomushroom Nov 16, 2024
441ab49
[prompt snippets]: ensure codecs work well with UTF16 codepoints
legomushroom Nov 18, 2024
8e77b66
[prompt snippets]: add `randomInt()` utility and related tests
legomushroom Nov 18, 2024
45f6f9d
[prompt snippets]: refactor and add more unit tests
legomushroom Nov 19, 2024
6393f29
[prompt snippets]: fix unresolved `Buffer` import reference
legomushroom Nov 19, 2024
51ca856
[prompt snippets]: refactor `LinesDecoder` to use `VSBuffer` as under…
legomushroom Nov 19, 2024
1541bcf
[prompt snippets]: make the `ImplicitContext` to create prompt file r…
legomushroom Nov 19, 2024
002aae4
[prompt snippets]: make the `ChatDynamicVariable` to resolve prompt f…
legomushroom Nov 19, 2024
d3b826e
[prompt snippets]: localize (+N more) labels
legomushroom Nov 19, 2024
0717ad7
[prompt snippets]: pre PR cleanups
legomushroom Nov 19, 2024
cde24d1
[prompt snippets]: minor cleanups
legomushroom Nov 19, 2024
12651e0
[prompt snippets]: address some PR feedback, fix an unit test issue
legomushroom Nov 21, 2024
7b6151e
[prompt snippets]: move file to common layers
legomushroom Nov 22, 2024
7ba7102
[prompt snippets]: move base codec types to base/common
legomushroom Nov 22, 2024
dc90f20
[prompt snippets]: move more codec files around
legomushroom Nov 22, 2024
062dfee
[prompt snippets]: update a code comment
legomushroom Nov 22, 2024
531122b
[prompt snippets]: fix `assert.throws()` API incompatibility issue
legomushroom Nov 22, 2024
bbb5002
[prompt snippets]: minor cleanup
legomushroom Nov 22, 2024
8576011
[prompt snippets]: improve unit tests for the `PromptFileReference`
legomushroom Nov 22, 2024
80ef092
[prompt snippets]: skip unit tests of `PromptFileReference` on Window…
legomushroom Nov 22, 2024
7993f20
[prompt snippets]: address PR feedback
legomushroom Nov 22, 2024
2e23acb
[prompt snippets]: add `PromptFileReference.isPromptSnippetFile` getter
legomushroom Nov 22, 2024
6171dd1
[prompt snippets]: move the `assertDefined` utility to `types.ts`
legomushroom Nov 22, 2024
95de12c
use service injection in `PromptFileReference` class
legomushroom Nov 23, 2024
2663542
[prompt snippets]: remove formatting changes
legomushroom Nov 25, 2024
1828231
[prompt snippets]: remove more formatting changes
legomushroom Nov 25, 2024
7d0c960
[prompt snippets]: revert more formatting changes
legomushroom Nov 25, 2024
1273227
[prompt snippets]: add logic to dispose existing variables in `ChatDy…
legomushroom Nov 25, 2024
b5bc41f
[prompt snippets]: cleanup
legomushroom Nov 25, 2024
c59f37f
[prompt snippets]: minor cleanup
legomushroom Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/git/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ export function debounce(delay: number): Function {
this[timerKey] = setTimeout(() => fn.apply(this, args), delay);
};
});
}
}
78 changes: 78 additions & 0 deletions src/vs/base/common/codecs/asyncDecoder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Disposable } from '../lifecycle.js';
import { BaseDecoder } from './baseDecoder.js';

/**
* Asynchronous interator wrapper for a decoder.
*/
export class AsyncDecoder<T extends NonNullable<unknown>, K extends NonNullable<unknown> = NonNullable<unknown>> extends Disposable {
// Buffer of messages that have been decoded but not yet consumed.
private readonly messages: T[] = [];

/**
* A transient promise that is resolved when a new event
* is received. Used in the situation when there is no new
* data avaialble and decoder stream did not finish yet,
* hence we need to wait until new event is received.
*/
private resolveOnNewEvent?: (value: void) => void;

/**
* @param decoder The decoder instance to wrap.
*/
constructor(
private readonly decoder: BaseDecoder<T, K>,
) {
super();
}

/**
* Async iterator implementation.
*/
async *[Symbol.asyncIterator](): AsyncIterator<T | null> {
// callback is called when `data` or `end` event is received
const callback = (data?: T) => {
if (data !== undefined) {
this.messages.push(data);
} else {
this.decoder.removeListener('data', callback);
this.decoder.removeListener('end', callback);
}

// is the promise resolve callback is present,
// then call it and remove the reference
if (this.resolveOnNewEvent) {
this.resolveOnNewEvent();
delete this.resolveOnNewEvent;
}
};
this.decoder.on('data', callback);
this.decoder.on('end', callback);

// start flowing the decoder stream
this.decoder.start();

while (true) {
const maybeMessage = this.messages.shift();
if (maybeMessage !== undefined) {
yield maybeMessage;
continue;
}

// if no data and stream ended, so we're done
if (this.decoder.isEnded) {
return null;
}

// stream isn't ended so wait for the new
// `data` or `end` event to be received
await new Promise((resolve) => {
this.resolveOnNewEvent = resolve;
});
}
}
}
Loading
Loading