Skip to content

Commit

Permalink
Conversation actions names and descriptions (#8826)
Browse files Browse the repository at this point in the history
* move name to variables

* Fix conversation query table name and description

* fix
  • Loading branch information
spolu authored Nov 22, 2024
1 parent b0ebcc3 commit b9ffd7f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
16 changes: 15 additions & 1 deletion front/lib/api/assistant/actions/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@
export const DEFAULT_BROWSE_ACTION_NAME = "browse";
export const DEFAULT_PROCESS_ACTION_NAME =
"extract_structured_data_from_data_sources";

export const DEFAULT_RETRIEVAL_ACTION_NAME = "search_data_sources";

// The name below is used by the assistant builder when the user selects "Include data".
export const DEFAULT_RETRIEVAL_NO_QUERY_ACTION_NAME =
"most_recent_in_data_sources";

export const DEFAULT_WEBSEARCH_ACTION_NAME = "web_search";
export const DEFAULT_WEBSEARCH_ACTION_DESCRIPTION = "Perform a web search";

export const DEFAULT_TABLES_QUERY_ACTION_NAME = "query_tables";
export const DEFAULT_VISUALIZATION_ACTION_NAME = "visualization";

export const DEFAULT_CONVERSATION_LIST_FILES_ACTION_NAME =
"list_conversation_files";

export const DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_NAME =
"include_conversation_file";
export const DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_DESCRIPTION = `Retrieve and read an 'includable' conversation file as returned by \`${DEFAULT_CONVERSATION_LIST_FILES_ACTION_NAME}\``;

export const DEFAULT_CONVERSATION_QUERY_TABLES_ACTION_NAME =
"query_conversation_tables";
export const DEFAULT_CONVERSATION_QUERY_TABLES_ACTION_DATA_DESCRIPTION = `The tables associated with the 'queryable' conversation files as returned by \`${DEFAULT_CONVERSATION_LIST_FILES_ACTION_NAME}\``;
19 changes: 13 additions & 6 deletions front/lib/api/assistant/actions/conversation/include_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import {
isTextContent,
} from "@dust-tt/types";

import {
DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_DESCRIPTION,
DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_NAME,
} from "@app/lib/api/assistant/actions/constants";
import type { BaseActionRunParams } from "@app/lib/api/assistant/actions/types";
import { BaseActionConfigurationServerRunner } from "@app/lib/api/assistant/actions/types";
import config from "@app/lib/api/config";
Expand Down Expand Up @@ -151,7 +155,8 @@ export class ConversationIncludeFileAction extends BaseAction {
renderForFunctionCall(): FunctionCallType {
return {
id: this.functionCallId ?? `call_${this.id.toString()}`,
name: this.functionCallName ?? "include_conversation_file",
name:
this.functionCallName ?? DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_NAME,
arguments: JSON.stringify(this.params),
};
}
Expand All @@ -166,7 +171,9 @@ export class ConversationIncludeFileAction extends BaseAction {
const finalize = (content: string) => {
return {
role: "function" as const,
name: this.functionCallName ?? "include_conversation_file",
name:
this.functionCallName ??
DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_NAME,
function_call_id: this.functionCallId ?? `call_${this.id.toString()}`,
content,
};
Expand Down Expand Up @@ -226,7 +233,8 @@ export class ConversationIncludeFileConfigurationServerRunner extends BaseAction

return new Ok({
name,
description: description || "Retrieve the content of a file attachment",
description:
description ?? DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_DESCRIPTION,
inputs: [
{
name: "fileId",
Expand Down Expand Up @@ -423,8 +431,7 @@ export function makeConversationIncludeFileConfiguration(): ConversationIncludeF
id: -1,
sId: generateRandomModelSId(),
type: "conversation_include_file_configuration",
name: "include_conversation_file",
description:
"Retrieve and read an includable conversation file as returned by `list_conversation_files`",
name: DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_NAME,
description: DEFAULT_CONVERSATION_INCLUDE_FILE_ACTION_DESCRIPTION,
};
}
9 changes: 6 additions & 3 deletions front/lib/api/assistant/actions/conversation/list_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import { BaseAction } from "@dust-tt/types";
import _ from "lodash";

import { DEFAULT_CONVERSATION_LIST_FILES_ACTION_NAME } from "@app/lib/api/assistant/actions/constants";
import { isConversationIncludableFileContentType } from "@app/lib/api/assistant/actions/conversation/include_file";

interface ConversationListFilesActionBlob {
Expand Down Expand Up @@ -38,7 +39,8 @@ export class ConversationListFilesAction extends BaseAction {
renderForFunctionCall(): FunctionCallType {
return {
id: this.functionCallId ?? `call_${this.id.toString()}`,
name: this.functionCallName ?? "list_conversation_files",
name:
this.functionCallName ?? DEFAULT_CONVERSATION_LIST_FILES_ACTION_NAME,
arguments: JSON.stringify({}),
};
}
Expand All @@ -64,7 +66,8 @@ export class ConversationListFilesAction extends BaseAction {

return {
role: "function" as const,
name: this.functionCallName ?? "list_conversation_files",
name:
this.functionCallName ?? DEFAULT_CONVERSATION_LIST_FILES_ACTION_NAME,
function_call_id: this.functionCallId ?? `call_${this.id.toString()}`,
content,
};
Expand All @@ -84,7 +87,7 @@ export function makeConversationListFilesAction({

return new ConversationListFilesAction({
functionCallId: "call_" + Math.random().toString(36).substring(7),
functionCallName: "list_conversation_files",
functionCallName: DEFAULT_CONVERSATION_LIST_FILES_ACTION_NAME,
files,
agentMessageId: agentMessage.agentMessageId,
});
Expand Down
15 changes: 10 additions & 5 deletions front/lib/api/assistant/jit_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import {
} from "@dust-tt/types";
import assert from "assert";

import {
DEFAULT_CONVERSATION_QUERY_TABLES_ACTION_DATA_DESCRIPTION,
DEFAULT_CONVERSATION_QUERY_TABLES_ACTION_NAME,
} from "@app/lib/api/assistant/actions/constants";
import { makeConversationIncludeFileConfiguration } from "@app/lib/api/assistant/actions/conversation/include_file";
import { makeConversationListFilesAction } from "@app/lib/api/assistant/actions/conversation/list_files";
import {
Expand Down Expand Up @@ -142,15 +146,16 @@ async function getJITActions(
);

if (filesUsableAsTableQuery.length > 0) {
// TODO(jit) Shall we look for an existing table query action and update it instead of
// TODO(JIT) Shall we look for an existing table query action and update it instead of
// creating a new one? This would allow join between the tables.
const action: TablesQueryConfigurationType = {
description: filesUsableAsTableQuery
.map((f) => `tableId: ${f.fileId}\n${f.snippet}`)
.join("\n\n"),
// The description here is the description of the data, a meta description of the action
// is prepended automatically.
description:
DEFAULT_CONVERSATION_QUERY_TABLES_ACTION_DATA_DESCRIPTION,
type: "tables_query_configuration",
id: -1,
name: "query_conversation_tables",
name: DEFAULT_CONVERSATION_QUERY_TABLES_ACTION_NAME,
sId: generateRandomModelSId(),
tables: filesUsableAsTableQuery.map((f) => ({
workspaceId: auth.getNonNullableWorkspace().sId,
Expand Down

0 comments on commit b9ffd7f

Please sign in to comment.