Skip to content

Commit e5c0808

Browse files
committed
feat(chat): implement Google Search integration and update workflows
- Add Google Search toggle to chat interface - Implement chat/google-search command in ChatController - Add isGoogleSearchEnabled parameter to completion and chat handlers - Update googleChatClient with conditional Google search tools - Add Google search toggle methods to ChatBuilder - Add isGoogleSearchEnabled prop to HumanMessageEditor - Update version to 1.71.0+1 - Remove experimental and nightly GitHub workflow files
1 parent cad51ac commit e5c0808

File tree

10 files changed

+35
-192
lines changed

10 files changed

+35
-192
lines changed

.github/workflows/release-vscode-experimental.yml

-92
This file was deleted.

.github/workflows/release-vscode-nightly.yml

-95
This file was deleted.

lib/shared/src/llm-providers/google/chat-client.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function googleChatClient({
8383
})
8484
}
8585
}
86-
const hasSearch = (model as Model).clientSideConfig?.options?.googleSearch
86+
const hasSearch =
87+
(model as Model).clientSideConfig?.options?.googleSearch && params.isGoogleSearchEnabled
8788
const tools = hasSearch ? [{ google_search: {} }] : []
8889
const configs = isGeminiThinkModel ? { thinkingConfig: { includeThoughts: true } } : {}
8990

lib/shared/src/sourcegraph-api/completions/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface CompletionParameters {
5656
model?: string
5757
stream?: boolean
5858
images?: ImageData[]
59+
isGoogleSearchEnabled?: boolean
5960
// Configuration for a Predicted Output, which can greatly improve response
6061
// times when large parts of the model response are known ahead of time.
6162
// https://platform.openai.com/docs/guides/latency-optimization#use-predicted-outputs

vscode/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "cody-ai",
44
"private": true,
55
"displayName": "Cody: AI Code Assistant",
6-
"version": "1.71.0+0",
6+
"version": "1.71.0+1",
77
"publisher": "sourcegraph",
88
"license": "Apache-2.0",
99
"icon": "resources/sourcegraph.png",

vscode/src/chat/chat-view/ChatBuilder.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class ChatBuilder {
9696
public readonly sessionID: string = new Date(Date.now()).toUTCString(),
9797
private messages: ChatMessage[] = [],
9898
private customChatTitle?: string,
99-
private images: ImageData[] = []
99+
private images: ImageData[] = [],
100+
private isGoogleSearchEnabled = false
100101
) {}
101102

102103
/** An observable that emits whenever the {@link ChatBuilder}'s chat changes. */
@@ -388,6 +389,24 @@ export class ChatBuilder {
388389
// Default to jpeg if unknown
389390
return 'image/jpeg'
390391
}
392+
393+
/**
394+
* Sets the Google search toggle to enabled.
395+
*/
396+
public async setGoogleSearchToggle(): Promise<void> {
397+
this.isGoogleSearchEnabled = true
398+
}
399+
400+
/**
401+
* Retrieves the current state of the Google search toggle and resets it to disabled.
402+
*
403+
* @returns The previous state of the Google search toggle, indicating whether it was enabled or disabled.
404+
*/
405+
public getAndResetGoogleSearchToggle(): boolean {
406+
const isGoogleSearchEnabled = this.isGoogleSearchEnabled
407+
this.isGoogleSearchEnabled = false
408+
return isGoogleSearchEnabled
409+
}
391410
}
392411

393412
function messageToSerializedChatInteraction(

vscode/src/chat/chat-view/ChatController.ts

+4
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv
561561
await this.chatBuilder.addImage(message.image)
562562
break
563563
}
564+
case 'chat/google-search': {
565+
await this.chatBuilder.setGoogleSearchToggle()
566+
break
567+
}
564568
}
565569
}
566570

vscode/src/chat/chat-view/handlers/ChatHandler.ts

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export class ChatHandler implements AgentHandler {
155155
model,
156156
maxTokensToSample: contextWindow.output,
157157
images: chatBuilder.getAndResetImages(),
158+
isGoogleSearchEnabled: chatBuilder.getAndResetGoogleSearchToggle(),
158159
} as CompletionParameters
159160

160161
// Set stream param only when the model is disabled for streaming.

vscode/src/chat/protocol.ts

+3
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ export type WebviewMessage =
177177
command: 'openRelativeFile'
178178
uri: Uri
179179
}
180+
| {
181+
command: 'chat/google-search'
182+
}
180183

181184
export interface SmartApplyResult {
182185
taskId: FixupTaskID

vscode/webviews/chat/cells/messageCell/human/editor/HumanMessageEditor.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ export const HumanMessageEditor: FunctionComponent<{
223223
}
224224
setImageFile(undefined)
225225
processImage()
226-
/* const processGoogleSearch = async () => {
226+
const processGoogleSearch = async () => {
227227
if (isGoogleSearchEnabled) {
228228
getVSCodeAPI().postMessage({
229229
command: 'chat/google-search',
230230
})
231231
}
232232
}
233-
processGoogleSearch() */
233+
processGoogleSearch()
234234

235235
parentOnSubmit(intent)
236236

@@ -257,6 +257,7 @@ export const HumanMessageEditor: FunctionComponent<{
257257
isSent,
258258
imageFile,
259259
setImageFile,
260+
isGoogleSearchEnabled,
260261
]
261262
)
262263

0 commit comments

Comments
 (0)