Skip to content

Commit

Permalink
feat(chat): implement Google Search integration and update workflows
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
PriNova committed Feb 21, 2025
1 parent cad51ac commit e5c0808
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 192 deletions.
92 changes: 0 additions & 92 deletions .github/workflows/release-vscode-experimental.yml

This file was deleted.

95 changes: 0 additions & 95 deletions .github/workflows/release-vscode-nightly.yml

This file was deleted.

3 changes: 2 additions & 1 deletion lib/shared/src/llm-providers/google/chat-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export async function googleChatClient({
})
}
}
const hasSearch = (model as Model).clientSideConfig?.options?.googleSearch
const hasSearch =
(model as Model).clientSideConfig?.options?.googleSearch && params.isGoogleSearchEnabled
const tools = hasSearch ? [{ google_search: {} }] : []
const configs = isGeminiThinkModel ? { thinkingConfig: { includeThoughts: true } } : {}

Expand Down
1 change: 1 addition & 0 deletions lib/shared/src/sourcegraph-api/completions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface CompletionParameters {
model?: string
stream?: boolean
images?: ImageData[]
isGoogleSearchEnabled?: boolean
// Configuration for a Predicted Output, which can greatly improve response
// times when large parts of the model response are known ahead of time.
// https://platform.openai.com/docs/guides/latency-optimization#use-predicted-outputs
Expand Down
2 changes: 1 addition & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "cody-ai",
"private": true,
"displayName": "Cody: AI Code Assistant",
"version": "1.71.0+0",
"version": "1.71.0+1",
"publisher": "sourcegraph",
"license": "Apache-2.0",
"icon": "resources/sourcegraph.png",
Expand Down
21 changes: 20 additions & 1 deletion vscode/src/chat/chat-view/ChatBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export class ChatBuilder {
public readonly sessionID: string = new Date(Date.now()).toUTCString(),
private messages: ChatMessage[] = [],
private customChatTitle?: string,
private images: ImageData[] = []
private images: ImageData[] = [],
private isGoogleSearchEnabled = false
) {}

/** An observable that emits whenever the {@link ChatBuilder}'s chat changes. */
Expand Down Expand Up @@ -388,6 +389,24 @@ export class ChatBuilder {
// Default to jpeg if unknown
return 'image/jpeg'
}

/**
* Sets the Google search toggle to enabled.
*/
public async setGoogleSearchToggle(): Promise<void> {
this.isGoogleSearchEnabled = true
}

/**
* Retrieves the current state of the Google search toggle and resets it to disabled.
*
* @returns The previous state of the Google search toggle, indicating whether it was enabled or disabled.
*/
public getAndResetGoogleSearchToggle(): boolean {
const isGoogleSearchEnabled = this.isGoogleSearchEnabled
this.isGoogleSearchEnabled = false
return isGoogleSearchEnabled
}
}

function messageToSerializedChatInteraction(
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/chat/chat-view/ChatController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv
await this.chatBuilder.addImage(message.image)
break
}
case 'chat/google-search': {
await this.chatBuilder.setGoogleSearchToggle()
break
}
}
}

Expand Down
1 change: 1 addition & 0 deletions vscode/src/chat/chat-view/handlers/ChatHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class ChatHandler implements AgentHandler {
model,
maxTokensToSample: contextWindow.output,
images: chatBuilder.getAndResetImages(),
isGoogleSearchEnabled: chatBuilder.getAndResetGoogleSearchToggle(),
} as CompletionParameters

// Set stream param only when the model is disabled for streaming.
Expand Down
3 changes: 3 additions & 0 deletions vscode/src/chat/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ export type WebviewMessage =
command: 'openRelativeFile'
uri: Uri
}
| {
command: 'chat/google-search'
}

export interface SmartApplyResult {
taskId: FixupTaskID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ export const HumanMessageEditor: FunctionComponent<{
}
setImageFile(undefined)
processImage()
/* const processGoogleSearch = async () => {
const processGoogleSearch = async () => {
if (isGoogleSearchEnabled) {
getVSCodeAPI().postMessage({
command: 'chat/google-search',
})
}
}
processGoogleSearch() */
processGoogleSearch()

parentOnSubmit(intent)

Expand All @@ -257,6 +257,7 @@ export const HumanMessageEditor: FunctionComponent<{
isSent,
imageFile,
setImageFile,
isGoogleSearchEnabled,
]
)

Expand Down

0 comments on commit e5c0808

Please sign in to comment.