Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit539db98

Browse files
committed
add option to disable markup and cell outputs
1 parentc36cdff commit539db98

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

‎package.json‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@
3636
{
3737
"title":"Llama coder",
3838
"properties": {
39+
"notebook.includeMarkup": {
40+
"type":"boolean",
41+
"default":true,
42+
"description":"Include markup cell types in prompt"
43+
},
44+
"notebook.includeCellOutputs": {
45+
"type":"boolean",
46+
"default":false,
47+
"description":"Include Cell previous output results in the prompt"
48+
},
49+
"notebook.cellOutputLimit": {
50+
"type":"number",
51+
"default":256,
52+
"description":"truncate cell output result if exceeds this limit"
53+
},
3954
"inference.endpoint": {
4055
"type":"string",
4156
"default":"",
@@ -121,7 +136,7 @@
121136
"pretest":"yarn run compile && yarn run lint",
122137
"lint":"eslint src --ext ts",
123138
"test":"jest",
124-
"package":"vsce package"
139+
"package":"npx @vscode/vsce package"
125140
},
126141
"devDependencies": {
127142
"@types/jest":"^29.5.10",

‎src/config.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ class Config {
4545
};
4646
}
4747

48+
// Notebook
49+
getnotebook(){
50+
letconfig=vscode.workspace.getConfiguration('notebook');
51+
52+
letincludeMarkup=config.get('includeMarkup')asboolean;
53+
letincludeCellOutputs=config.get('includeCellOutputs')asboolean;
54+
letcellOutputLimit=config.get('cellOutputLimit')asnumber;
55+
return{
56+
includeMarkup,
57+
includeCellOutputs,
58+
cellOutputLimit,
59+
};
60+
}
61+
4862
get #config(){
4963
returnvscode.workspace.getConfiguration('inference');
5064
};

‎src/prompts/preparePrompt.ts‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import vscode from 'vscode';
22
import{detectLanguage}from'./processors/detectLanguage';
33
import{fileHeaders}from'./processors/fileHeaders';
44
import{languages}from'./processors/languages';
5+
import{config}from'../config';
56

67
vardecoder=newTextDecoder("utf8");
78

@@ -13,12 +14,13 @@ function getNotebookDocument(document: vscode.TextDocument): vscode.NotebookDocu
1314
exportasyncfunctionpreparePrompt(document:vscode.TextDocument,position:vscode.Position,context:vscode.InlineCompletionContext){
1415

1516
// Load document text
16-
console.log(document);
1717
lettext=document.getText();
1818
letoffset=document.offsetAt(position);
1919
letprefix=text.slice(0,offset);
2020
letsuffix:string=text.slice(offset);
2121

22+
letnotebookConfig=config.notebook;
23+
2224
// If this is a notebook, add the surrounding cells to the prefix and suffix
2325
letnotebookDocument=getNotebookDocument(document);
2426
letlanguage=detectLanguage(document.uri.fsPath,document.languageId);
@@ -43,21 +45,26 @@ export async function preparePrompt(document: vscode.TextDocument, position: vsc
4345

4446
// add the markdown cell output to the prompt as a comment
4547
if(cell.kind===vscode.NotebookCellKind.Markup&&commentStart){
46-
for(constlineofcell.document.getText().split('\n')){
47-
out+=`\n${commentStart}${line}`;
48+
if(notebookConfig.includeMarkup){
49+
for(constlineofcell.document.getText().split('\n')){
50+
out+=`\n${commentStart}${line}`;
51+
}
4852
}
4953
}else{
5054
out+=cell.document.getText();
5155
}
5256

5357
// if there is any outputs add them to the prompt as a comment
54-
if(cell.kind===vscode.NotebookCellKind.Code&&commentStart){
55-
console.log(cell.outputs);
58+
constaddCellOutputs=notebookConfig.includeCellOutputs
59+
&&beforeCurrentCell
60+
&&cell.kind===vscode.NotebookCellKind.Code
61+
&&commentStart;
62+
if(addCellOutputs){
5663
letcellOutputs=cell.outputs
5764
.map(x=>x.items
5865
.filter(x=>x.mime==='text/plain')
5966
.map(x=>decoder.decode(x.data))
60-
.map(x=>x.slice(0,256).split('\n')))// limit to 256 characters
67+
.map(x=>x.slice(0,notebookConfig.cellOutputLimit).split('\n')))
6168
.flat(3);
6269

6370
if(cellOutputs.length>0){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp