Skip to content

Commit

Permalink
remove experimental plugins feature (#904)
Browse files Browse the repository at this point in the history
This is not being used right now.
  • Loading branch information
sqs authored Sep 5, 2023
1 parent ae2b292 commit 4d82e3d
Show file tree
Hide file tree
Showing 35 changed files with 26 additions and 1,211 deletions.
25 changes: 6 additions & 19 deletions lib/shared/src/chat/transcript/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ContextFile, ContextMessage, OldContextMessage, PreciseContext } from '../../codebase-context/messages'
import { PluginFunctionExecutionInfo } from '../../plugins/api/types'
import { CHARS_PER_TOKEN, MAX_AVAILABLE_PROMPT_LENGTH } from '../../prompt/constants'
import { PromptMixin } from '../../prompt/prompt-mixin'
import { Message } from '../../sourcegraph-api'
Expand Down Expand Up @@ -37,7 +36,6 @@ export class Transcript {
usedContextFiles,
usedPreciseContext,
timestamp,
pluginExecutionInfos,
}) => {
if (!fullContext) {
fullContext = context || []
Expand All @@ -61,8 +59,7 @@ export class Transcript {
),
usedContextFiles || [],
usedPreciseContext || [],
timestamp || new Date().toISOString(),
pluginExecutionInfos || []
timestamp || new Date().toISOString()
)
}
),
Expand Down Expand Up @@ -166,7 +163,6 @@ export class Transcript {
public async getPromptForLastInteraction(
preamble: Message[] = [],
maxPromptLength: number = MAX_AVAILABLE_PROMPT_LENGTH,
pluginsPrompt: Message[] = [],
onlyHumanMessages: boolean = false
): Promise<{ prompt: Message[]; contextFiles: ContextFile[]; preciseContexts: PreciseContext[] }> {
if (this.interactions.length === 0) {
Expand All @@ -181,18 +177,14 @@ export class Transcript {
const assistantMessage = interaction.getAssistantMessage()
const contextMessages = await interaction.getFullContext()
if (index === lastInteractionWithContextIndex && !onlyHumanMessages) {
messages.push(...contextMessages, ...pluginsPrompt, humanMessage, assistantMessage)
messages.push(...contextMessages, humanMessage, assistantMessage)
} else {
messages.push(...pluginsPrompt, humanMessage, assistantMessage)
messages.push(humanMessage, assistantMessage)
}
}

const preambleTokensUsage = preamble.reduce((acc, message) => acc + estimateTokensUsage(message), 0)
const pluginPreambleTokenUsage = pluginsPrompt.reduce((acc, message) => acc + estimateTokensUsage(message), 0)
let truncatedMessages = truncatePrompt(
messages,
maxPromptLength - preambleTokensUsage - pluginPreambleTokenUsage
)
let truncatedMessages = truncatePrompt(messages, maxPromptLength - preambleTokensUsage)
// Return what context fits in the window
const contextFiles: ContextFile[] = []
const preciseContexts: PreciseContext[] = []
Expand Down Expand Up @@ -220,17 +212,12 @@ export class Transcript {

public setUsedContextFilesForLastInteraction(
contextFiles: ContextFile[],
preciseContexts: PreciseContext[] = [],
pluginExecutionInfos: PluginFunctionExecutionInfo[] = []
preciseContexts: PreciseContext[] = []
): void {
if (this.interactions.length === 0) {
throw new Error('Cannot set context files for empty transcript')
}
this.interactions[this.interactions.length - 1].setUsedContext(
contextFiles,
pluginExecutionInfos,
preciseContexts
)
this.interactions[this.interactions.length - 1].setUsedContext(contextFiles, preciseContexts)
}

public toChat(): ChatMessage[] {
Expand Down
14 changes: 2 additions & 12 deletions lib/shared/src/chat/transcript/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ContextFile, ContextMessage, PreciseContext } from '../../codebase-context/messages'
import { PluginFunctionExecutionInfo } from '../../plugins/api/types'

import { ChatMessage, InteractionMessage } from './messages'

Expand All @@ -9,7 +8,6 @@ export interface InteractionJSON {
fullContext: ContextMessage[]
usedContextFiles: ContextFile[]
usedPreciseContext: PreciseContext[]
pluginExecutionInfos: PluginFunctionExecutionInfo[]
timestamp: string

// DEPRECATED: Legacy field for backcompat, renamed to `fullContext`
Expand All @@ -23,8 +21,7 @@ export class Interaction {
private fullContext: Promise<ContextMessage[]>,
private usedContextFiles: ContextFile[],
private usedPreciseContext: PreciseContext[] = [],
public readonly timestamp: string = new Date().toISOString(),
private pluginExecutionInfos: PluginFunctionExecutionInfo[] = []
public readonly timestamp: string = new Date().toISOString()
) {}

public getAssistantMessage(): InteractionMessage {
Expand All @@ -49,13 +46,8 @@ export class Interaction {
return contextMessages.length > 0
}

public setUsedContext(
usedContextFiles: ContextFile[],
pluginExecutionInfos: PluginFunctionExecutionInfo[],
usedPreciseContext: PreciseContext[]
): void {
public setUsedContext(usedContextFiles: ContextFile[], usedPreciseContext: PreciseContext[]): void {
this.usedContextFiles = usedContextFiles
this.pluginExecutionInfos = pluginExecutionInfos
this.usedPreciseContext = usedPreciseContext
}

Expand All @@ -69,7 +61,6 @@ export class Interaction {
...this.assistantMessage,
contextFiles: this.usedContextFiles,
preciseContext: this.usedPreciseContext,
pluginExecutionInfos: this.pluginExecutionInfos,
},
]
}
Expand All @@ -86,7 +77,6 @@ export class Interaction {
fullContext: await this.fullContext,
usedContextFiles: this.usedContextFiles,
usedPreciseContext: this.usedPreciseContext,
pluginExecutionInfos: this.pluginExecutionInfos,
timestamp: this.timestamp,
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/shared/src/chat/transcript/messages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ContextFile, PreciseContext } from '../../codebase-context/messages'
import { PluginFunctionExecutionInfo } from '../../plugins/api/types'
import { Message } from '../../sourcegraph-api'

import { TranscriptJSON } from '.'
Expand All @@ -14,7 +13,6 @@ export interface ChatMessage extends Message {
displayText?: string
contextFiles?: ContextFile[]
preciseContext?: PreciseContext[]
pluginExecutionInfos?: PluginFunctionExecutionInfo[]
buttons?: ChatButton[]
data?: any
}
Expand Down
18 changes: 0 additions & 18 deletions lib/shared/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,7 @@ export interface Configuration {
autocompleteAdvancedEmbeddings: boolean
autocompleteExperimentalCompleteSuggestWidgetSelection?: boolean
autocompleteExperimentalSyntacticPostProcessing?: boolean
pluginsEnabled?: boolean
pluginsDebugEnabled?: boolean
isRunningInsideAgent?: boolean
pluginsConfig?: {
confluence?: {
baseUrl: string
email?: string
apiToken?: string
}
github?: {
apiToken?: string
baseURL?: string
org?: string
repo?: string
}
apiNinjas?: {
apiKey?: string
}
}
}

export interface ConfigurationWithAccessToken extends Configuration {
Expand Down
125 changes: 0 additions & 125 deletions lib/shared/src/plugins/api/index.ts

This file was deleted.

52 changes: 0 additions & 52 deletions lib/shared/src/plugins/api/prompt.ts

This file was deleted.

Loading

0 comments on commit 4d82e3d

Please sign in to comment.