Skip to content

Commit 370a850

Browse files
authored
[Components] griptape - new components (#15741)
1 parent b347438 commit 370a850

File tree

6 files changed

+456
-9
lines changed

6 files changed

+456
-9
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import app from "../../griptape.app.mjs";
2+
3+
export default {
4+
key: "griptape-create-assistant",
5+
name: "Create Assistant",
6+
description: "Creates a new assistant in Griptape. [See the documentation](https://docs.griptape.ai/stable/griptape-cloud/api/api-reference/#/Assistants/CreateAssistant)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
name: {
12+
propDefinition: [
13+
app,
14+
"name",
15+
],
16+
},
17+
description: {
18+
propDefinition: [
19+
app,
20+
"description",
21+
],
22+
},
23+
input: {
24+
propDefinition: [
25+
app,
26+
"input",
27+
],
28+
},
29+
knowledgeBaseIds: {
30+
type: "string[]",
31+
label: "Knowledge Base IDs",
32+
description: "The knowledge base IDs of the assistant",
33+
optional: true,
34+
propDefinition: [
35+
app,
36+
"knowledgeBaseId",
37+
],
38+
},
39+
rulesetIds: {
40+
type: "string[]",
41+
label: "Ruleset IDs",
42+
description: "The ruleset IDs of the assistant",
43+
optional: true,
44+
propDefinition: [
45+
app,
46+
"rulesetId",
47+
],
48+
},
49+
structureIds: {
50+
type: "string[]",
51+
label: "Structure IDs",
52+
description: "The structure IDs of the assistant",
53+
optional: true,
54+
propDefinition: [
55+
app,
56+
"structureId",
57+
],
58+
},
59+
toolIds: {
60+
type: "string[]",
61+
label: "Tool IDs",
62+
description: "The tool IDs of the assistant",
63+
optional: true,
64+
propDefinition: [
65+
app,
66+
"toolId",
67+
],
68+
},
69+
},
70+
methods: {
71+
createAssistant(args = {}) {
72+
return this.app.post({
73+
path: "/assistants",
74+
...args,
75+
});
76+
},
77+
},
78+
async run({ $ }) {
79+
const {
80+
createAssistant,
81+
name,
82+
description,
83+
input,
84+
knowledgeBaseIds,
85+
rulesetIds,
86+
structureIds,
87+
toolIds,
88+
} = this;
89+
90+
const response = await createAssistant({
91+
$,
92+
data: {
93+
name,
94+
description,
95+
input,
96+
knowledge_base_ids: knowledgeBaseIds,
97+
ruleset_ids: rulesetIds,
98+
structure_ids: structureIds,
99+
tool_ids: toolIds,
100+
},
101+
});
102+
$.export("$summary", `Successfully created a new assistant with ID \`${response.assistant_id}\`.`);
103+
return response;
104+
},
105+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import app from "../../griptape.app.mjs";
2+
3+
export default {
4+
key: "griptape-delete-assistant",
5+
name: "Delete Assistant",
6+
description: "Deletes an existing assistant. [See the documentation](https://docs.griptape.ai/stable/griptape-cloud/api/api-reference/#/Assistants/DeleteAssistant).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
assistantId: {
12+
propDefinition: [
13+
app,
14+
"assistantId",
15+
],
16+
},
17+
},
18+
methods: {
19+
deleteAssistant({
20+
assistantId, ...args
21+
} = {}) {
22+
return this.app.delete({
23+
path: `/assistants/${assistantId}`,
24+
...args,
25+
});
26+
},
27+
},
28+
async run({ $ }) {
29+
const {
30+
deleteAssistant,
31+
assistantId,
32+
} = this;
33+
34+
await deleteAssistant({
35+
$,
36+
assistantId,
37+
});
38+
$.export("$summary", "Successfully deleted assistant");
39+
return {
40+
success: true,
41+
};
42+
},
43+
};
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import app from "../../griptape.app.mjs";
2+
3+
export default {
4+
key: "griptape-update-assistant",
5+
name: "Update Assistant",
6+
description: "Updates an existing assistant. [See the documentation](https://docs.griptape.ai/stable/griptape-cloud/api/api-reference/#/Assistants/UpdateAssistant).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
assistantId: {
12+
propDefinition: [
13+
app,
14+
"assistantId",
15+
],
16+
},
17+
name: {
18+
optional: true,
19+
propDefinition: [
20+
app,
21+
"name",
22+
],
23+
},
24+
description: {
25+
propDefinition: [
26+
app,
27+
"description",
28+
],
29+
},
30+
input: {
31+
optional: true,
32+
propDefinition: [
33+
app,
34+
"input",
35+
],
36+
},
37+
knowledgeBaseIds: {
38+
type: "string[]",
39+
label: "Knowledge Base IDs",
40+
description: "The knowledge base IDs of the assistant",
41+
optional: true,
42+
propDefinition: [
43+
app,
44+
"knowledgeBaseId",
45+
],
46+
},
47+
rulesetIds: {
48+
type: "string[]",
49+
label: "Ruleset IDs",
50+
description: "The ruleset IDs of the assistant",
51+
optional: true,
52+
propDefinition: [
53+
app,
54+
"rulesetId",
55+
],
56+
},
57+
structureIds: {
58+
type: "string[]",
59+
label: "Structure IDs",
60+
description: "The structure IDs of the assistant",
61+
optional: true,
62+
propDefinition: [
63+
app,
64+
"structureId",
65+
],
66+
},
67+
toolIds: {
68+
type: "string[]",
69+
label: "Tool IDs",
70+
description: "The tool IDs of the assistant",
71+
optional: true,
72+
propDefinition: [
73+
app,
74+
"toolId",
75+
],
76+
},
77+
},
78+
methods: {
79+
updateAssistant({
80+
assistantId, ...args
81+
} = {}) {
82+
return this.app.patch({
83+
path: `/assistants/${assistantId}`,
84+
...args,
85+
});
86+
},
87+
},
88+
async run({ $ }) {
89+
const {
90+
updateAssistant,
91+
assistantId,
92+
name,
93+
description,
94+
input,
95+
knowledgeBaseIds,
96+
rulesetIds,
97+
structureIds,
98+
toolIds,
99+
} = this;
100+
101+
const response = await updateAssistant({
102+
$,
103+
assistantId,
104+
data: {
105+
name,
106+
description,
107+
input,
108+
knowledge_base_ids: knowledgeBaseIds,
109+
ruleset_ids: rulesetIds,
110+
structure_ids: structureIds,
111+
tool_ids: toolIds,
112+
},
113+
});
114+
$.export("$summary", `Successfully updated assistant with ID \`${response.assistant_id}\`.`);
115+
return response;
116+
},
117+
};

0 commit comments

Comments
 (0)