Skip to content

Commit 4430c0d

Browse files
committed
Added requested changes
1 parent 44373f7 commit 4430c0d

File tree

7 files changed

+337
-10
lines changed

7 files changed

+337
-10
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import app from "../../x_ai.app.mjs";
2+
3+
export default {
4+
key: "x_ai-create-embeddings",
5+
name: "Create Embedding",
6+
description: "Create an embedding vector representation corresponding to the input text. [See the documentation](https://docs.x.ai/api/endpoints#create-embeddings)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
embeddingModel: {
12+
propDefinition: [
13+
app,
14+
"embeddingModel",
15+
],
16+
},
17+
input: {
18+
propDefinition: [
19+
app,
20+
"input",
21+
],
22+
},
23+
dimensions: {
24+
propDefinition: [
25+
app,
26+
"dimensions",
27+
],
28+
},
29+
encodingFormat: {
30+
propDefinition: [
31+
app,
32+
"encodingFormat",
33+
],
34+
},
35+
user: {
36+
propDefinition: [
37+
app,
38+
"user",
39+
],
40+
},
41+
},
42+
43+
async run({ $ }) {
44+
const response = await this.app.createEmbeddings({
45+
$,
46+
data: {
47+
dimensions: this.dimensions,
48+
encoding_format: this.encodingFormat,
49+
input: this.input,
50+
model: this.embeddingModel,
51+
user: this.user,
52+
},
53+
});
54+
$.export("$summary", "Successfully created embedding");
55+
return response;
56+
},
57+
};

components/x_ai/actions/get-model/get-model.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export default {
2121
$,
2222
model: this.model,
2323
});
24-
2524
$.export("$summary", `Successfully retrieved the '${this.model}' model`);
26-
2725
return response;
2826
},
2927
};

components/x_ai/actions/post-chat-completion/post-chat-completion.mjs

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,66 @@ export default {
2020
"message",
2121
],
2222
},
23+
frequencyPenalty: {
24+
propDefinition: [
25+
app,
26+
"frequencyPenalty",
27+
],
28+
},
29+
logprobs: {
30+
propDefinition: [
31+
app,
32+
"logprobs",
33+
],
34+
},
35+
maxTokens: {
36+
propDefinition: [
37+
app,
38+
"maxTokens",
39+
],
40+
},
41+
n: {
42+
propDefinition: [
43+
app,
44+
"n",
45+
],
46+
},
47+
presencePenalty: {
48+
propDefinition: [
49+
app,
50+
"presencePenalty",
51+
],
52+
},
53+
seed: {
54+
propDefinition: [
55+
app,
56+
"seed",
57+
],
58+
},
59+
stream: {
60+
propDefinition: [
61+
app,
62+
"stream",
63+
],
64+
},
65+
temperature: {
66+
propDefinition: [
67+
app,
68+
"temperature",
69+
],
70+
},
71+
topP: {
72+
propDefinition: [
73+
app,
74+
"topP",
75+
],
76+
},
77+
user: {
78+
propDefinition: [
79+
app,
80+
"user",
81+
],
82+
},
2383
},
2484

2585
async run({ $ }) {
@@ -33,11 +93,19 @@ export default {
3393
content: this.message,
3494
},
3595
],
96+
frequency_penalty: Number(this.frequencyPenalty),
97+
logprobs: this.logprobs,
98+
max_tokens: this.maxTokens,
99+
n: this.n,
100+
presence_penalty: Number(this.presencePenalty),
101+
seed: this.seed,
102+
stream: this.stream,
103+
temperature: Number(this.temperature),
104+
top_p: Number(this.topP),
105+
user: this.user,
36106
},
37107
});
38-
39108
$.export("$summary", `Successfully sent message to the model '${this.model}'`);
40-
41109
return response;
42110
},
43111
};

components/x_ai/actions/post-completion/post-completion.mjs

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,78 @@ export default {
2020
"prompt",
2121
],
2222
},
23+
echo: {
24+
propDefinition: [
25+
app,
26+
"echo",
27+
],
28+
},
29+
frequencyPenalty: {
30+
propDefinition: [
31+
app,
32+
"frequencyPenalty",
33+
],
34+
},
35+
logprobs: {
36+
propDefinition: [
37+
app,
38+
"logprobs",
39+
],
40+
},
41+
maxTokens: {
42+
propDefinition: [
43+
app,
44+
"maxTokens",
45+
],
46+
},
47+
n: {
48+
propDefinition: [
49+
app,
50+
"n",
51+
],
52+
},
53+
presencePenalty: {
54+
propDefinition: [
55+
app,
56+
"presencePenalty",
57+
],
58+
},
59+
seed: {
60+
propDefinition: [
61+
app,
62+
"seed",
63+
],
64+
},
65+
stream: {
66+
propDefinition: [
67+
app,
68+
"stream",
69+
],
70+
},
71+
suffix: {
72+
propDefinition: [
73+
app,
74+
"suffix",
75+
],
76+
},
77+
temperature: {
78+
propDefinition: [
79+
app,
80+
"temperature",
81+
],
82+
},
83+
topP: {
84+
propDefinition: [
85+
app,
86+
"topP",
87+
],
88+
},
89+
user: {
90+
propDefinition: [
91+
app,
92+
"user",
93+
],
94+
},
2395
},
2496

2597
async run({ $ }) {
@@ -28,11 +100,21 @@ export default {
28100
data: {
29101
model: this.model,
30102
prompt: this.prompt,
103+
echo: this.echo,
104+
frequency_penalty: Number(this.frequencyPenalty),
105+
logprobs: this.logprobs,
106+
max_tokens: this.maxTokens,
107+
n: this.n,
108+
presence_penalty: Number(this.presencePenalty),
109+
seed: this.seed,
110+
stream: this.stream,
111+
suffix: this.suffix,
112+
temperature: Number(this.temperature),
113+
top_p: Number(this.topP),
114+
user: this.user,
31115
},
32116
});
33-
34117
$.export("$summary", `Successfully sent prompt to the model '${this.model}'`);
35-
36118
return response;
37119
},
38120
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
ENCODING_FORMATS: [
3+
"float",
4+
"base64",
5+
],
6+
};

components/x_ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pipedream/x_ai",
33
"version": "0.1.0",
4-
"description": "Pipedream X AI Components",
4+
"description": "Pipedream Chat Data Components",
55
"main": "x_ai.app.mjs",
66
"keywords": [
77
"pipedream",

0 commit comments

Comments
 (0)