ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / extension / prompts / node / panel / notebookVariables.tsx 157 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import { BasePromptElementProps , PromptElement , PromptElementProps , PromptSizing , TextChunk , TokenLimit } from '@vscode/prompt-tsx' ;
import type * as vscode from 'vscode' ;
import { ILogService } from '../../../../platform/log/common/logService' ;
import { parseAndCleanStack } from '../../../../platform/notebook/common/helpers' ;
import { INotebookService , VariablesResult }
notebook vscode
variables
props
@ notebookService
@ _promptPathRepresentationService
@ logger
props
override
variables
variables
error
variables
state
filePath
isJupyterNotebook
notebookType isJupyterNotebook
state
state
notebookType filePath
state variable
variable variable variable
outputUri
props
@ workspaceService
@ promptPathRepresentationService
@ promptEndpoint
props
state sizing
outputUri
outputInfo outputUri
outputInfo
notebook cell notebookCellOutput outputInfo
outputIndex cell notebookCellOutput
allowedTextMimeTypes
item notebookCellOutput notebookCellOutput
item allowedTextMimeTypes item item
text
cellIndex cell
notebookPath notebook
item
text
text cellIndex notebookPath
textSize sizing
textChunk item
item item
textChunk textChunk
textChunk textSize
textChunk textChunk textSize
text
textChunk
text
from
'../../../../platform/notebook/common/notebookService'
;
import
{ IPromptPathRepresentationService }
from
'../../../../platform/prompts/common/promptPathRepresentationService'
;
import
{ IWorkspaceService }
from
'../../../../platform/workspace/common/workspaceService'
;
import
{ getNotebookCellOutput, isJupyterNotebookUri }
from
'../../../../util/common/notebooks'
;
import
{
URI
}
from
'../../../../util/vs/base/common/uri'
;
import
{ IPromptEndpoint }
from
'../base/promptRenderer'
;
import
{ Tag }
from
'../base/tag'
;
import
{ getCharLimit }
from
'../inline/summarizedDocument/summarizeDocumentHelpers'
;
import
{ Image }
from
'./image'
;
type
NotebookVariablesPromptProps
=
PromptElementProps
<
{
:
.
NotebookDocument
;
}
>
;
interface
InlineChatNotebookRuntimeState
{
:
VariablesResult
[
]
;
}
export
class
NotebookVariables
extends
PromptElement< NotebookVariablesPromptProps, InlineChatNotebookRuntimeState>
{
constructor
(
:
NotebookVariablesPromptProps
,
INotebookService
private
readonly
:
INotebookService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
ILogService
private
readonly
:
ILogService
,
)
{
super
(
)
;
}
async
prepare
(
)
:
Promise
<
InlineChatNotebookRuntimeState
>
{
try
{
this
.
logger
.
trace
(
` Fetching notebook variables for ${ this . props. notebook. uri. toString ( ) } `
)
;
const
=
await
this
.
notebookService
.
getVariables
(
this
.
props
.
notebook
.
uri
)
;
return
{
}
;
}
catch
(
)
{
this
.
logger
.
error
(
` Failed to get notebook variables for ${ this . props. notebook. uri. toString ( ) } : ${ error} `
)
;
return
{
:
[
]
}
;
}
}
render
(
:
InlineChatNotebookRuntimeState
)
{
const
=
this
.
_promptPathRepresentationService
.
getFilePath
(
this
.
props
.
notebook
.
uri
)
;
const
=
isJupyterNotebookUri
(
this
.
props
.
notebook
.
uri
)
;
const
=
?
'Jupyter Notebook'
:
'Notebook'
;
if
(
.
variables
.
length
===
0
)
{
return
(
< >
</ >
)
;
}
return
(
< TokenLimit max = { 16384 } >
<notebook-kernel-variables>
< br />
{
.
variables
.
length
!==
0
&&
< >
The following variables are present in the
{
}
{
}
:
{
.
variables
.
map
(
(
)
=>
(
< >
< TextChunk >
Name:
{
.
variable
.
name
}
< br />
{
.
variable
.
type
&&
< >
Type:
{
.
variable
.
type
}
</ >
}
< br />
</ TextChunk >
</ >
)
)
}
</ >
}
</notebook-kernel-variables>
< br />
</ TokenLimit >
)
;
}
}
export
interface
INotebookCellOutputProps
extends
BasePromptElementProps
{
:
URI
;
}
export
class
NotebookCellOutputVariable
extends
PromptElement< INotebookCellOutputProps>
{
constructor
(
:
PromptElementProps
<
INotebookCellOutputProps
>
,
IWorkspaceService
private
readonly
:
IWorkspaceService
,
IPromptPathRepresentationService
private
readonly
:
IPromptPathRepresentationService
,
IPromptEndpoint
private
readonly
:
IPromptEndpoint
)
{
super
(
)
;
}
render
(
:
void
,
:
PromptSizing
)
{
const
=
this
.
props
.
outputUri
;
const
=
getNotebookCellOutput
(
,
this
.
workspaceService
.
notebookDocuments
)
;
if
(
!
)
{
return
;
}
const
[
,
,
]
=
;
const
=
.
outputs
.
indexOf
(
)
;
const
=
[
'text/plain'
,
'text/html'
,
'text/markdown'
,
'application/vnd.code.notebook.stdout'
,
'application/vnd.code.notebook.error'
,
'application/vnd.code.notebook.stderr'
]
;
const
=
.
items
.
length
?
.
items
[
0
]
:
undefined
;
if
(
!
||
(
!
.
includes
(
.
mime
)
&&
!
.
mime
.
startsWith
(
'image/'
)
)
)
{
return
< >
</ >
;
}
let
;
const
=
.
index
;
const
=
this
.
promptPathRepresentationService
.
getFilePath
(
.
uri
)
;
if
(
.
mime
===
'image/png'
)
{
if
(
this
.
promptEndpoint
.
supportsVision
)
{
=
(
< >
< br />
< Tag name = { ` cell-output ` } attrs = { { mimeType: item. mime , outputIndex, cellIndex, notebookPath } } >
< Image variableName = { ` cell-output-image- ${ outputIndex} ` } variableValue = { item. data } />
</ Tag >
</ >
)
;
}
else
{
=
(
< >
< br />
The user attempted to attach an image which is the output from the cell with index:
{
}
of the notebook
{
}
but
images cannot be sent to this endpoint at this time and is therefore not attached.
< br />
< br />
</ >
)
;
}
}
else
{
const
=
getCharLimit
(
.
tokenBudget
/
4
)
;
let
=
.
data
.
toString
(
)
;
if
(
.
mime
===
'application/vnd.code.notebook.stderr'
||
.
mime
===
'application/vnd.code.notebook.error'
)
{
=
parseAndCleanStack
(
)
;
}
if
(
.
length
>
)
{
=
.
substring
(
0
,
)
;
}
=
(
< >
< br />
< Tag name = { ` notebook-cell-output ` } attrs = { { mimeType: item. mime , outputIndex, cellIndex, notebookPath } } >
{
}
</ Tag >
</ >
)
;
}
return
;
}
}