Skip to content

Commit a580121

Browse files
committed
clean up ui
1 parent 3dda1b2 commit a580121

3 files changed

Lines changed: 2 additions & 67 deletions

File tree

packages/core/src/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ export const IMAGE_GENERATION_MODEL_ID = "image"
7979
export const EMBEDDINGS_MODEL_ID = "embeddings"
8080
export const DEFAULT_FENCE_FORMAT: FenceFormat = "xml"
8181
export const DEFAULT_TEMPERATURE = 0.8
82-
export const CACHE_LLMREQUEST_PREFIX = "genaiscript/cache/llm/"
83-
export const CACHE_AIREQUEST_TRACE_PREFIX = "genaiscript/cache/ai/trace/"
84-
export const CACHE_AIREQUEST_TEXT_PREFIX = "genaiscript/cache/ai/text/"
8582
export const TRACE_NODE_PREFIX = "genaiscript/trace/"
8683
export const EXTENSION_ID = "genaiscript.genaiscript-vscode"
8784
export const COPILOT_CHAT_PARTICIPANT_ID = TOOL_ID

packages/vscode/src/chatparticipant.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
COPILOT_CHAT_PARTICIPANT_SCRIPT_ID,
66
COPILOT_CHAT_PARTICIPANT_ID,
77
ICON_LOGO_NAME,
8-
CACHE_AIREQUEST_TRACE_PREFIX,
9-
CACHE_AIREQUEST_TEXT_PREFIX,
108
} from "../../core/src/constants"
119
import { Fragment } from "../../core/src/generation"
1210
import { convertAnnotationsToItems } from "../../core/src/annotations"
@@ -163,10 +161,7 @@ export async function activateChatParticipant(state: ExtensionState) {
163161
const { text = "", status, statusText } = res || {}
164162
if (status !== "success") md("$(error) " + statusText)
165163
if (text) md("\n\n" + convertAnnotationsToItems(text))
166-
md(
167-
`\n\n[output](command:genaiscript.request.open?${encodeURIComponent(JSON.stringify([CACHE_AIREQUEST_TEXT_PREFIX + res.requestSha + ".md"]))}) | [trace](command:genaiscript.request.open?${encodeURIComponent(JSON.stringify([CACHE_AIREQUEST_TRACE_PREFIX + res.requestSha + ".md"]))})`,
168-
"genaiscript.request.open"
169-
)
164+
// TODO open url
170165
}
171166
)
172167
participant.iconPath = new vscode.ThemeIcon(ICON_LOGO_NAME)

packages/vscode/src/markdowndocumentprovider.ts

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ import {
99
import { showMarkdownPreview } from "./markdown"
1010
import { registerCommand } from "./commands"
1111
import { 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"
1913
import { prettifyMarkdown } from "../../core/src/markdown"
2014
import {
2115
logprobToMarkdown,
@@ -109,59 +103,8 @@ ${prettifyMarkdown(md)}
109103
.replace(/\.md$/, "")
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(/\.md$/, "")
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(/\.md$/, "")
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(/\.md$/, "")
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

167110
export function infoUri(path: string) {

0 commit comments

Comments
 (0)