Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable tools per bot #234

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/ai/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type BotConfig struct {
CustomInstructions string `json:"customInstructions"`
Service ServiceConfig `json:"service"`
EnableVision bool `json:"enableVision"`
DisableTools bool `json:"disableTools"`
}

func (c *BotConfig) IsValid() bool {
Expand Down
2 changes: 1 addition & 1 deletion server/api_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (p *Plugin) handleSince(c *gin.Context) {
"type": promptPreset,
})

prompt, err := p.prompts.ChatCompletion(promptPreset, context, p.getDefaultToolsStore(context.IsDMWithBot()))
prompt, err := p.prompts.ChatCompletion(promptPreset, context, p.getDefaultToolsStore(bot, context.IsDMWithBot()))
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
Expand Down
5 changes: 4 additions & 1 deletion server/built_in_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,10 @@ func (p *Plugin) getBuiltInTools(isDM bool) []ai.Tool {
return builtInTools
}

func (p *Plugin) getDefaultToolsStore(isDM bool) ai.ToolStore {
func (p *Plugin) getDefaultToolsStore(bot *Bot, isDM bool) ai.ToolStore {
if bot == nil || bot.cfg.DisableTools {
return ai.NewNoTools()
}
store := ai.NewToolStore(&p.pluginAPI.Log, p.getConfiguration().EnableLLMTrace)
store.AddTools(p.getBuiltInTools(isDM))
return store
Expand Down
4 changes: 2 additions & 2 deletions server/meeting_summarization.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (p *Plugin) summarizeTranscription(bot *Bot, transcription *subtitles.Subti
p.pluginAPI.Log.Debug("Split into chunks", "chunks", len(chunks))
for _, chunk := range chunks {
context.PromptParameters = map[string]string{"TranscriptionChunk": chunk}
summarizeChunkPrompt, err := p.prompts.ChatCompletion(ai.PromptSummarizeChunk, context, p.getDefaultToolsStore(context.IsDMWithBot()))
summarizeChunkPrompt, err := p.prompts.ChatCompletion(ai.PromptSummarizeChunk, context, p.getDefaultToolsStore(bot, context.IsDMWithBot()))
if err != nil {
return nil, fmt.Errorf("unable to get summarize chunk prompt: %w", err)
}
Expand All @@ -291,7 +291,7 @@ func (p *Plugin) summarizeTranscription(bot *Bot, transcription *subtitles.Subti
}

context.PromptParameters = map[string]string{"Transcription": llmFormattedTranscription, "IsChunked": fmt.Sprintf("%t", isChunked)}
summaryPrompt, err := p.prompts.ChatCompletion(ai.PromptMeetingSummary, context, p.getDefaultToolsStore(context.IsDMWithBot()))
summaryPrompt, err := p.prompts.ChatCompletion(ai.PromptMeetingSummary, context, p.getDefaultToolsStore(bot, context.IsDMWithBot()))
if err != nil {
return nil, fmt.Errorf("unable to get meeting summary prompt: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (p *Plugin) processUserRequestToBot(bot *Bot, context ai.ConversationContex
}

func (p *Plugin) newConversation(bot *Bot, context ai.ConversationContext) error {
conversation, err := p.prompts.ChatCompletion(ai.PromptDirectMessageQuestion, context, p.getDefaultToolsStore(context.IsDMWithBot()))
conversation, err := p.prompts.ChatCompletion(ai.PromptDirectMessageQuestion, context, p.getDefaultToolsStore(bot, context.IsDMWithBot()))
if err != nil {
return err
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (p *Plugin) continueConversation(bot *Bot, threadData *ThreadData, context
return nil, err
}
} else {
prompt, err := p.prompts.ChatCompletion(ai.PromptDirectMessageQuestion, context, p.getDefaultToolsStore(context.IsDMWithBot()))
prompt, err := p.prompts.ChatCompletion(ai.PromptDirectMessageQuestion, context, p.getDefaultToolsStore(bot, context.IsDMWithBot()))
if err != nil {
return nil, err
}
Expand All @@ -151,7 +151,7 @@ func (p *Plugin) continueThreadConversation(bot *Bot, questionThreadData *Thread
originalThread := formatThread(originalThreadData)

context.PromptParameters = map[string]string{"Thread": originalThread}
prompt, err := p.prompts.ChatCompletion(ai.PromptSummarizeThread, context, p.getDefaultToolsStore(context.IsDMWithBot()))
prompt, err := p.prompts.ChatCompletion(ai.PromptSummarizeThread, context, p.getDefaultToolsStore(bot, context.IsDMWithBot()))
if err != nil {
return nil, err
}
Expand All @@ -177,7 +177,7 @@ func (p *Plugin) summarizePost(bot *Bot, postIDToSummarize string, context ai.Co
formattedThread := formatThread(threadData)

context.PromptParameters = map[string]string{"Thread": formattedThread}
prompt, err := p.prompts.ChatCompletion(ai.PromptSummarizeThread, context, p.getDefaultToolsStore(context.IsDMWithBot()))
prompt, err := p.prompts.ChatCompletion(ai.PromptSummarizeThread, context, p.getDefaultToolsStore(bot, context.IsDMWithBot()))
if err != nil {
return nil, err
}
Expand Down
33 changes: 22 additions & 11 deletions webapp/src/components/system_console/bot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type LLMBotConfig = {
service: LLMService
customInstructions: string
enableVision: boolean
disableTools: boolean
}

type Props = {
Expand Down Expand Up @@ -135,17 +136,27 @@ const Bot = (props: Props) => {
onChange={(e) => props.onChange({...props.bot, customInstructions: e.target.value})}
/>
{ (props.bot.service.type === 'openai' || props.bot.service.type === 'openaicompatible') && (
<BooleanItem
label={
<Horizontal>
<FormattedMessage defaultMessage='Enable Vision'/>
<Pill><FormattedMessage defaultMessage='BETA'/></Pill>
</Horizontal>
}
value={props.bot.enableVision}
onChange={(to: boolean) => props.onChange({...props.bot, enableVision: to})}
helpText={intl.formatMessage({defaultMessage: 'Enable Vision to allow the bot to process images. Requires a compatible model.'})}
/>
<>
<BooleanItem
label={
<Horizontal>
<FormattedMessage defaultMessage='Enable Vision'/>
<Pill><FormattedMessage defaultMessage='BETA'/></Pill>
</Horizontal>
}
value={props.bot.enableVision}
onChange={(to: boolean) => props.onChange({...props.bot, enableVision: to})}
helpText={intl.formatMessage({defaultMessage: 'Enable Vision to allow the bot to process images. Requires a compatible model.'})}
/>
<BooleanItem
label={
<FormattedMessage defaultMessage='Disable Tools'/>
}
value={props.bot.disableTools}
onChange={(to: boolean) => props.onChange({...props.bot, disableTools: to})}
helpText={intl.formatMessage({defaultMessage: 'By default some tool use is enabled to allow for features such as integrations with JIRA. Disabling this allows use of models that do not support or are not very good at tool use. Some features will not work without tools.'})}
/>
</>
)}
</ItemList>
</ItemListContainer>
Expand Down
1 change: 1 addition & 0 deletions webapp/src/components/system_console/bots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const defaultNewBot = {
streamingTimeoutSeconds: 0,
},
enableVision: false,
disableTools: false,
};

export const firstNewBot = {
Expand Down