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 / image.tsx 133 строк · изменён 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
import { RequestType } from '@vscode/copilot-api' ;
import * as l10n from '@vscode/l10n' ;
import { Image as BaseImage , BasePromptElementProps , ChatResponseReferencePartStatusKind , PromptElement , PromptReference , PromptSizing , UserMessage } from '@vscode/prompt-tsx' ;
import { IAuthenticationService } from '../../../../platform/authentication/common/authentication' ;
import
variableName
variableValue
omitReferences
reference
src
detail
mimeType
endpoint
endpoint
props
@ promptEndpoint
props
override _state sizing
props
@ promptEndpoint
@ authService
@ logService
@ imageService
@ configurationService
props
override _state sizing
noVisionDescription l10n
omittedOptions status description noVisionDescription kind
fillerUri
variable
imageSource variable
imageMimeType
isChatRequest
enabled
isChatRequest enabled
githubToken silent accessToken
mimeType imageSource imageMimeType
uri variable mimeType githubToken
uri
imageSource uri
imageMimeType mimeType
error
err
{
ConfigKey
,
IConfigurationService
}
from
'../../../../platform/configuration/common/configurationService'
;
import
{ modelCanUseImageURL }
from
'../../../../platform/endpoint/common/chatModelCapabilities'
;
import
{ IImageService }
from
'../../../../platform/image/common/imageService'
;
import
{ ILogService }
from
'../../../../platform/log/common/logService'
;
import
{ getMimeType }
from
'../../../../util/common/imageUtils'
;
import
{ Uri }
from
'../../../../vscodeTypes'
;
import
{ IPromptEndpoint }
from
'../base/promptRenderer'
;
export
interface
ImageProps
extends
BasePromptElementProps
{
:
string
;
:
Uint8Array
|
Promise
<
Uint8Array
>
;
?
:
boolean
;
?
:
Uri
;
}
export
interface
HistoricalImageProps
extends
BasePromptElementProps
{
:
string
;
?
:
'auto'
|
'low'
|
'high'
;
?
:
string
;
}
function
canSendImage
(
:
IPromptEndpoint
)
:
boolean
{
return
.
supportsVision
;
}
export
class
HistoricalImage
extends
PromptElement< HistoricalImageProps, unknown >
{
constructor
(
:
HistoricalImageProps
,
IPromptEndpoint
private
readonly
:
IPromptEndpoint
,
)
{
super
(
)
;
}
async
render
(
:
unknown
,
:
PromptSizing
)
{
if
(
!
canSendImage
(
this
.
promptEndpoint
)
)
{
return
undefined
;
}
return
< BaseImage src = { this . props . src } detail = { this . props . detail } mimeType = { this . props . mimeType } />
;
}
}
export
class
Image
extends
PromptElement< ImageProps, unknown >
{
constructor
(
:
ImageProps
,
IPromptEndpoint
private
readonly
:
IPromptEndpoint
,
IAuthenticationService
private
readonly
:
IAuthenticationService
,
ILogService
private
readonly
:
ILogService
,
IImageService
private
readonly
:
IImageService
,
IConfigurationService
private
readonly
:
IConfigurationService
)
{
super
(
)
;
}
async
render
(
:
unknown
,
:
PromptSizing
)
{
const
=
.
t
(
"{0} does not support images."
,
this
.
promptEndpoint
.
model
)
;
const
=
{
:
{
:
,
:
ChatResponseReferencePartStatusKind
.
Omitted
}
}
;
const
:
Uri
=
this
.
props
.
reference
??
Uri
.
parse
(
'Attached Image'
)
;
try
{
if
(
!
canSendImage
(
this
.
promptEndpoint
)
)
{
if
(
this
.
props
.
omitReferences
)
{
return
;
}
return
(
< >
< references value = { [ new PromptReference ( this . props . variableName ? { variableName: this . props . variableName , value: fillerUri } : fillerUri, undefined , omittedOptions) ] } />
</ >
)
;
}
const
=
await
this
.
props
.
variableValue
;
let
=
Buffer
.
from
(
)
.
toString
(
'base64'
)
;
let
:
string
|
undefined
=
undefined
;
const
=
typeof
this
.
promptEndpoint
.
urlOrRequestMetadata
!==
'string'
&&
(
this
.
promptEndpoint
.
urlOrRequestMetadata
.
type
===
RequestType
.
ChatCompletions
||
this
.
promptEndpoint
.
urlOrRequestMetadata
.
type
===
RequestType
.
ChatResponses
||
this
.
promptEndpoint
.
urlOrRequestMetadata
.
type
===
RequestType
.
ChatMessages
)
;
const
=
this
.
configurationService
.
getConfig
(
ConfigKey
.
EnableChatImageUpload
)
;
if
(
&&
&&
modelCanUseImageURL
(
this
.
promptEndpoint
)
)
{
try
{
const
=
(
await
this
.
authService
.
getGitHubSession
(
'any'
,
{
:
true
}
)
)
?.
;
const
=
getMimeType
(
)
??
;
const
=
await
this
.
imageService
.
uploadChatImageAttachment
(
,
this
.
props
.
variableName
,
,
)
;
if
(
)
{
=
.
toString
(
)
;
=
;
}
}
catch
(
)
{
this
.
logService
.
warn
(
` Image upload failed, using base64 fallback: ${ error} `
)
;
}
}
return
(
< UserMessage priority = { 0 } >
< BaseImage src = { imageSource} detail = ' high' mimeType = { imageMimeType} />
{
this
.
props
.
reference
&&
(
< references value = { [ new PromptReference ( this . props . variableName ? { variableName: this . props . variableName , value: fillerUri } : fillerUri, undefined ) ] } />
)
}
</ UserMessage >
)
;
}
catch
(
)
{
if
(
this
.
props
.
omitReferences
)
{
return
;
}
return
(
< >
< references value = { [ new PromptReference ( this . props . variableName ? { variableName: this . props . variableName , value: fillerUri } : fillerUri, undefined , omittedOptions) ] } />
</ >
)
;
}
}
}