Skip to content

Commit 2d75379

Browse files
authored
Update index-url mutation (#27)
* Update index-url command * bump sdk * update package
1 parent b8a0862 commit 2d75379

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@team-plain/cli": minor
3+
---
4+
5+
Use knowledge source for index URL

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@changesets/cli": "^2.27.9"
1919
},
2020
"dependencies": {
21-
"@team-plain/typescript-sdk": "^5.10.0",
21+
"@team-plain/typescript-sdk": "^5.10.3",
2222
"commander": "^12.1.0"
2323
}
2424
}

src/index.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@ function handleError(message, requestId = "–") {
2828
process.exit(1);
2929
}
3030

31-
async function indexUrl(url, labelTypeIds = []) {
32-
const client = getClient();
33-
const res = await client.indexDocument({
34-
url,
35-
labelTypeIds,
36-
});
37-
if (res.error) {
38-
handleError(res.error.message, res.error.requestId);
39-
} else {
40-
console.log(`✅ Successfully indexed ${url}`);
41-
}
42-
}
43-
4431
program.name("plain").version(packageJson.version).description("Plain CLI");
4532

4633
program
@@ -51,7 +38,19 @@ program
5138
.argument("<url>")
5239
.option("-l, --labelTypeIds <labelTypeIds...>", "Array of label type IDs")
5340
.action(async (url, options) => {
54-
await indexUrl(url, options.labelTypeIds);
41+
const client = getClient();
42+
const res = await client.createKnowledgeSource({
43+
url,
44+
labelTypeIds: options.labelTypeIds || [],
45+
type: "URL",
46+
});
47+
if (res.error) {
48+
handleError(res.error.message, res.error.requestId);
49+
} else {
50+
console.log(
51+
`✅ Successfully indexed URL ${url} - The URL will be indexed and knowledge sources will be available in Plain. See https://plain.support.site/article/plain-ai-knowledge-sources for more information.`,
52+
);
53+
}
5554
});
5655

5756
program

0 commit comments

Comments
 (0)