MCPcopy Create free account
hub / github.com/microsoft/vscode-extension-samples / chatResponseToString

Function chatResponseToString

chat-sample/src/toolsPrompt.tsx:181–197  ·  view source on GitHub ↗

* Convert the stream of chat response parts into something that can be rendered in the prompt.

(response: vscode.ChatResponseTurn)

Source from the content-addressed store, hash-verified

179 * Convert the stream of chat response parts into something that can be rendered in the prompt.
180 */
181function chatResponseToString(response: vscode.ChatResponseTurn): string {
182 return response.response
183 .map((r) => {
184 if (r instanceof vscode.ChatResponseMarkdownPart) {
185 return r.value.value;
186 } else if (r instanceof vscode.ChatResponseAnchorPart) {
187 if (r.value instanceof vscode.Uri) {
188 return r.value.fsPath;
189 } else {
190 return r.value.uri.fsPath;
191 }
192 }
193
194 return '';
195 })
196 .join('');
197}
198
199interface PromptReferencesProps extends BasePromptElementProps {
200 references: ReadonlyArray<vscode.ChatPromptReference>;

Callers 1

renderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected