Skip to content

Commit deca7a0

Browse files
committed
refactor(cli): name the cli trieve and set the default tool config on setup so things can go less wrong
1 parent 9a8dc5a commit deca7a0

File tree

10 files changed

+104
-59
lines changed

10 files changed

+104
-59
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

clients/agentic-rag-cli/index.ts renamed to clients/cli/index.ts

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ interface UploadedFile {
2525

2626
const configDir = process.env.XDG_CONFIG_HOME || `${os.homedir()}/.config`;
2727
const config = new Conf({
28-
cwd: `${configDir}/trieve-cli`,
28+
cwd: `${configDir}/trieve`,
2929
configName: 'config',
3030
});
3131

3232
// Path for storing uploaded files tracking data
3333
const uploadedFilesPath = path.join(
34-
`${configDir}/trieve-cli`,
34+
`${configDir}/trieve`,
3535
'uploaded_files.json',
3636
);
3737

3838
// Path for storing topics data
39-
const topicsPath = path.join(`${configDir}/trieve-cli`, 'topics.json');
39+
const topicsPath = path.join(`${configDir}/trieve`, 'topics.json');
4040

4141
// Function to manage uploaded files tracking
4242
function manageUploadedFiles(
@@ -123,23 +123,23 @@ function ensureTrieveConfig() {
123123
chalk.red('Error: TRIEVE_API_KEY is not set in env or config.'),
124124
);
125125
console.log(chalk.yellow('Run the following command to set it:'));
126-
console.log(chalk.cyan('trieve-cli configure'));
126+
console.log(chalk.cyan('trieve configure'));
127127
process.exit(1);
128128
}
129129
if (!datasetId) {
130130
console.error(
131131
chalk.red('Error: TRIEVE_DATASET_ID is not set in env or config.'),
132132
);
133133
console.log(chalk.yellow('Run the following command to set it:'));
134-
console.log(chalk.cyan('trieve-cli configure'));
134+
console.log(chalk.cyan('trieve configure'));
135135
process.exit(1);
136136
}
137137
if (!organizationId) {
138138
console.error(
139139
chalk.red('Error: TRIEVE_ORGANIZATION_ID is not set in env or config.'),
140140
);
141141
console.log(chalk.yellow('Run the following command to set it:'));
142-
console.log(chalk.cyan('trieve-cli configure'));
142+
console.log(chalk.cyan('trieve configure'));
143143
process.exit(1);
144144
}
145145
return { apiKey, datasetId, organizationId };
@@ -179,7 +179,7 @@ const uploadFile = async (
179179
);
180180
console.log(
181181
chalk.cyan(
182-
`trieve-cli check-upload-status --tracking-id "${options.trackingId ?? `tracking-${filePath.split('/').pop() ?? filePath}`}"`,
182+
`trieve check-upload-status --tracking-id "${options.trackingId ?? `tracking-${filePath.split('/').pop() ?? filePath}`}"`,
183183
),
184184
);
185185

@@ -406,7 +406,7 @@ async function askQuestion(question: string): Promise<void> {
406406
'default-user-' + Math.random().toString(36).substring(2, 15);
407407

408408
const topicData = await trieveClient.createTopic({
409-
name: topicName,
409+
first_user_message: topicName,
410410
owner_id: ownerId,
411411
});
412412

@@ -421,6 +421,7 @@ async function askQuestion(question: string): Promise<void> {
421421
topic_id: topicData.id,
422422
new_message_content: question,
423423
use_agentic_search: true,
424+
model: 'o3',
424425
});
425426

426427
// Stream the response
@@ -600,7 +601,7 @@ function formatChunksCollapsible(chunks: ChunkMetadata[]): string {
600601
}
601602

602603
program
603-
.name('trieve-cli')
604+
.name('trieve')
604605
.description('A CLI tool for using Trieve')
605606
.version('1.0.0');
606607

@@ -617,29 +618,30 @@ program
617618
}
618619
});
619620

620-
// -t "Always use the search tool here when the user asks a question about some information you're supposed to have or some files."
621-
// -q "Write this as a maximum 5 word query with the keywords you think would be useful"
622-
623621
program
624622
.command('update-tool-config')
625623
.description('Update the tool configuration for a dataset')
626-
.requiredOption(
624+
.option(
627625
'-t, --tool-description <toolDescription>',
628626
'Description that tells the LLM when it should use the search tool to retrieve information from your dataset',
629627
"Always use the search tool here when the user asks a question about some information you're supposed to have or some files.",
630628
)
631-
.requiredOption(
629+
.option(
632630
'-q, --query-description <queryDescription>',
633631
'Description of how the LLM should write its search queries to retrieve relevant information from your dataset',
634632
'Write this as a maximum 5 word query with the keywords you think would be useful',
635633
)
634+
.option(
635+
'-s, --system-prompt <systemPrompt>',
636+
'Custom system prompt for the AI assistant',
637+
"You are an AI assistant that helps people find information in a set of documents. You have access to a search tool that can retrieve relevant information from the documents based on a query. When you need to find information, use the search tool by writing a concise query that captures the essence of what you're looking for. Be specific and use keywords that are likely to yield relevant results. Once you receive the search results, use them to answer the user's question accurately and comprehensively. If the search results do not contain the information you need, inform the user that you couldn't find an answer in the documents.",
638+
)
636639
.action(async (options) => {
637640
try {
638641
console.log(chalk.blue('🔧 Updating tool configuration...'));
639642

640643
const { apiKey, datasetId, organizationId } = ensureTrieveConfig();
641644

642-
// Initialize SDK with apiKey and datasetId from config
643645
const trieveClient: TrieveSDK = new TrieveSDK({
644646
apiKey,
645647
datasetId,
@@ -649,18 +651,17 @@ program
649651
const updatePayload: UpdateDatasetReqPayload = {
650652
dataset_id: datasetId,
651653
server_configuration: {
654+
SYSTEM_PROMPT: options.systemPrompt,
652655
TOOL_CONFIGURATION: {
653656
query_tool_options: {
654657
tool_description: options.toolDescription,
655658
query_parameter_description: options.queryDescription,
656659
price_filter_description:
657-
'The price or page range filter to use for the search',
660+
'The page range filter to use for the search',
658661

659-
max_price_option_description:
660-
'The maximum price or page to filter by',
662+
max_price_option_description: 'The maximum page to filter by',
661663

662-
min_price_option_description:
663-
'The minimum price or page to filter by',
664+
min_price_option_description: 'The minimum page to filter by',
664665
},
665666
},
666667
},
@@ -681,12 +682,20 @@ program
681682
.command('configure')
682683
.description('Set up or update your Trieve CLI configuration')
683684
.action(async () => {
685+
const { apiKey, datasetId, organizationId } = ensureTrieveConfig();
686+
687+
const trieveClient: TrieveSDK = new TrieveSDK({
688+
apiKey,
689+
datasetId,
690+
organizationId,
691+
});
692+
684693
const answers = await inquirer.prompt([
685694
{
686695
type: 'input',
687-
name: 'TRIEVE_API_KEY',
688-
message: 'Enter your TRIEVE_API_KEY:',
689-
default: (config.get('TRIEVE_API_KEY') as string) || '',
696+
name: 'TRIEVE_ORGANIZATION_ID',
697+
message: 'Enter your TRIEVE_ORGANIZATION_ID:',
698+
default: (config.get('TRIEVE_ORGANIZATION_ID') as string) || '',
690699
},
691700
{
692701
type: 'input',
@@ -696,9 +705,9 @@ program
696705
},
697706
{
698707
type: 'input',
699-
name: 'TRIEVE_ORGANIZATION_ID',
700-
message: 'Enter your TRIEVE_ORGANIZATION_ID:',
701-
default: (config.get('TRIEVE_ORGANIZATION_ID') as string) || '',
708+
name: 'TRIEVE_API_KEY',
709+
message: 'Enter your TRIEVE_API_KEY:',
710+
default: (config.get('TRIEVE_API_KEY') as string) || '',
702711
},
703712
{
704713
type: 'input',
@@ -711,6 +720,30 @@ program
711720
config.set('TRIEVE_DATASET_ID', answers.TRIEVE_DATASET_ID);
712721
config.set('TRIEVE_ORGANIZATION_ID', answers.TRIEVE_ORGANIZATION_ID);
713722
config.set('userId', answers.userId);
723+
724+
const updatePayload: UpdateDatasetReqPayload = {
725+
dataset_id: datasetId,
726+
server_configuration: {
727+
SYSTEM_PROMPT:
728+
"You are an AI assistant that helps people find information in a set of documents. You have access to a search tool that can retrieve relevant information from the documents based on a query. When you need to find information, use the search tool by writing a concise query that captures the essence of what you're looking for. Be specific and use keywords that are likely to yield relevant results. Once you receive the search results, use them to answer the user's question accurately and comprehensively. If the search results do not contain the information you need, inform the user that you couldn't find an answer in the documents.",
729+
TOOL_CONFIGURATION: {
730+
query_tool_options: {
731+
tool_description:
732+
"Always use the search tool here when the user asks a question about some information you're supposed to have or some files.",
733+
query_parameter_description:
734+
'Write this as a maximum 5 word query with the keywords you think would be useful',
735+
price_filter_description:
736+
'The page range filter to use for the search',
737+
738+
max_price_option_description: 'The maximum page to filter by',
739+
740+
min_price_option_description: 'The minimum page to filter by',
741+
},
742+
},
743+
},
744+
};
745+
746+
await trieveClient.updateDataset(updatePayload);
714747
console.log(chalk.green('✅ Configuration saved!'));
715748
});
716749

@@ -758,18 +791,4 @@ program
758791
}
759792
});
760793

761-
program.addHelpText(
762-
'after',
763-
`
764-
${chalk.yellow('Examples:')}
765-
$ ${chalk.green('trieve-cli configure')}
766-
$ ${chalk.green('trieve-cli upload path/to/file.txt -t my-tracking-id')}
767-
$ ${chalk.green('trieve-cli check-upload-status')}
768-
$ ${chalk.green('trieve-cli check-upload-status --tracking-id <tracking-id>')}
769-
$ ${chalk.green('trieve-cli ask "What is the capital of France?"')}
770-
$ ${chalk.green('trieve-cli ask')}
771-
$ ${chalk.green('trieve-cli update-tool-config -t "Use this tool to search for information about our products and services" -q "Write specific search queries to find relevant information from our knowledge base"')}
772-
`,
773-
);
774-
775794
program.parse();

clients/agentic-rag-cli/package-lock.json renamed to clients/cli/package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
{
2-
"name": "agentic-rag-cli",
3-
"version": "1.0.0",
2+
"name": "trieve-cli",
3+
"version": "0.0.1",
44
"type": "module",
55
"main": "dist/index.js",
66
"bin": {
7-
"trieve-cli": "dist/index.js"
7+
"trieve": "dist/index.js"
88
},
99
"scripts": {
1010
"build": "tsc",
1111
"start": "node dist/index.js",
1212
"lint": "eslint . --ext .ts",
1313
"lint:fix": "eslint . --ext .ts --fix",
1414
"format": "prettier --check .",
15-
"format:fix": "prettier --write .",
16-
"test": "echo \"Error: no test specified\" && exit 1"
15+
"format:fix": "prettier --write ."
1716
},
18-
"author": "",
19-
"license": "ISC",
20-
"description": "",
17+
"author": "Trieve Team <contact@trieve.ai>",
18+
"license": "MIT",
19+
"description": "Beta command-line interface for Trieve API that enables users to upload files and interact with them using agentic RAG (Retrieval Augmented Generation). Simplifies document management and Q&A workflows.",
2120
"devDependencies": {
2221
"@typescript-eslint/eslint-plugin": "^8.34.0",
2322
"@typescript-eslint/parser": "^8.34.0",
@@ -30,6 +29,6 @@
3029
"commander": "^14.0.0",
3130
"conf": "^14.0.0",
3231
"inquirer": "^12.6.3",
33-
"trieve-ts-sdk": "^0.0.120"
32+
"trieve-ts-sdk": "^0.0.121"
3433
}
3534
}
File renamed without changes.

clients/ts-sdk/openapi.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11668,6 +11668,11 @@
1166811668
"description": "Metadata is any metadata you want to associate w/ the event that is created from this request",
1166911669
"nullable": true
1167011670
},
11671+
"model": {
11672+
"type": "string",
11673+
"description": "Model name to use for the completion. If not specified, this defaults to the dataset's model.",
11674+
"nullable": true
11675+
},
1167111676
"new_message_content": {
1167211677
"type": "string",
1167311678
"description": "The content of the user message to attach to the topic and then generate an assistant message in response to.",
@@ -12784,6 +12789,11 @@
1278412789
"description": "Metadata is any metadata you want to associate w/ the event that is created from this request",
1278512790
"nullable": true
1278612791
},
12792+
"model": {
12793+
"type": "string",
12794+
"description": "Model name to use for the completion. If not specified, this defaults to the dataset's model.",
12795+
"nullable": true
12796+
},
1278712797
"new_message_content": {
1278812798
"type": "string",
1278912799
"description": "The new content of the message to replace the old content with.",
@@ -19388,6 +19398,11 @@
1938819398
"description": "Metadata is any metadata you want to associate w/ the event that is created from this request",
1938919399
"nullable": true
1939019400
},
19401+
"model": {
19402+
"type": "string",
19403+
"description": "Model name to use for the completion. If not specified, this defaults to the dataset's model.",
19404+
"nullable": true
19405+
},
1939119406
"no_result_message": {
1939219407
"type": "string",
1939319408
"description": "No result message for when there are no chunks found above the score threshold.",

clients/ts-sdk/src/types.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,10 @@ export type CreateMessageReqPayload = {
10821082
* Metadata is any metadata you want to associate w/ the event that is created from this request
10831083
*/
10841084
metadata?: unknown;
1085+
/**
1086+
* Model name to use for the completion. If not specified, this defaults to the dataset's model.
1087+
*/
1088+
model?: (string) | null;
10851089
/**
10861090
* The content of the user message to attach to the topic and then generate an assistant message in response to.
10871091
*/
@@ -1599,6 +1603,10 @@ export type EditMessageReqPayload = {
15991603
* Metadata is any metadata you want to associate w/ the event that is created from this request
16001604
*/
16011605
metadata?: unknown;
1606+
/**
1607+
* Model name to use for the completion. If not specified, this defaults to the dataset's model.
1608+
*/
1609+
model?: (string) | null;
16021610
/**
16031611
* The new content of the message to replace the old content with.
16041612
*/
@@ -3724,6 +3732,10 @@ export type RegenerateMessageReqPayload = {
37243732
* Metadata is any metadata you want to associate w/ the event that is created from this request
37253733
*/
37263734
metadata?: unknown;
3735+
/**
3736+
* Model name to use for the completion. If not specified, this defaults to the dataset's model.
3737+
*/
3738+
model?: (string) | null;
37273739
/**
37283740
* No result message for when there are no chunks found above the score threshold.
37293741
*/

0 commit comments

Comments
 (0)