@@ -9,13 +9,7 @@ import {
99import { showMarkdownPreview } from "./markdown"
1010import { registerCommand } from "./commands"
1111import { getChatCompletionCache } from "../../core/src/chatcache"
12- import {
13- TRACE_NODE_PREFIX ,
14- CACHE_LLMREQUEST_PREFIX ,
15- CACHE_AIREQUEST_TRACE_PREFIX ,
16- CACHE_AIREQUEST_TEXT_PREFIX ,
17- } from "../../core/src/constants"
18- import { extractFenced , renderFencedVariables } from "../../core/src/fence"
12+ import { TRACE_NODE_PREFIX } from "../../core/src/constants"
1913import { prettifyMarkdown } from "../../core/src/markdown"
2014import {
2115 logprobToMarkdown ,
@@ -109,59 +103,8 @@ ${prettifyMarkdown(md)}
109103 . replace ( / \. m d $ / , "" )
110104 return this . previewTraceNode ( id )
111105 }
112- if ( uri . path . startsWith ( CACHE_LLMREQUEST_PREFIX ) ) {
113- const sha = uri . path
114- . slice ( CACHE_LLMREQUEST_PREFIX . length )
115- . replace ( / \. m d $ / , "" )
116- return previewOpenAICacheEntry ( sha )
117- }
118- if ( uri . path . startsWith ( CACHE_AIREQUEST_TRACE_PREFIX ) ) {
119- const sha = uri . path
120- . slice ( CACHE_AIREQUEST_TRACE_PREFIX . length )
121- . replace ( / \. m d $ / , "" )
122- return this . previewAIRequest ( sha , "trace" )
123- }
124- if ( uri . path . startsWith ( CACHE_AIREQUEST_TEXT_PREFIX ) ) {
125- const sha = uri . path
126- . slice ( CACHE_AIREQUEST_TEXT_PREFIX . length )
127- . replace ( / \. m d $ / , "" )
128- return this . previewAIRequest ( sha , "text" )
129- }
130106 return ""
131107 }
132-
133- private async previewAIRequest ( sha : string , type : "trace" | "text" ) {
134- const cache = this . state . aiRequestCache ( )
135- const { val } = ( await cache . getEntryBySha ( sha ) ) || { }
136- if ( ! val )
137- return `## Oops
138-
139- Request \`${ sha } \` not found in cache.
140- `
141-
142- return type === "trace" ? val ?. trace : val ?. response ?. text
143- }
144- }
145-
146- async function previewOpenAICacheEntry ( sha : string ) {
147- const cache = getChatCompletionCache ( )
148- const { val } = ( await cache . getEntryBySha ( sha ) ) || { }
149- if ( ! val )
150- return `## Oops
151-
152- Request \`${ sha } \` not found in cache.
153- `
154-
155- const extr = extractFenced ( val . text )
156- return `# Cached Request
157-
158- - \`${ sha } \`
159-
160- \`\`\`\`\`json
161- ${ JSON . stringify ( val , null , 2 ) }
162- \`\`\`\`\`
163-
164- `
165108}
166109
167110export function infoUri ( path : string ) {
0 commit comments