Skip to content

Commit

Permalink
Merging pull request #14868
Browse files Browse the repository at this point in the history
* Added requested changes

* Added requested changes

* Added requested changes
  • Loading branch information
lcaresia authored Dec 9, 2024
1 parent 426d08a commit 63ac5ef
Show file tree
Hide file tree
Showing 7 changed files with 344 additions and 17 deletions.
57 changes: 57 additions & 0 deletions components/x_ai/actions/create-embeddings/create-embeddings.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import app from "../../x_ai.app.mjs";

export default {
key: "x_ai-create-embeddings",
name: "Create Embedding",
description: "Create an embedding vector representation corresponding to the input text. [See the documentation](https://docs.x.ai/api/endpoints#create-embeddings)",
version: "0.0.2",
type: "action",
props: {
app,
embeddingModel: {
propDefinition: [
app,
"embeddingModel",
],
},
input: {
propDefinition: [
app,
"input",
],
},
dimensions: {
propDefinition: [
app,
"dimensions",
],
},
encodingFormat: {
propDefinition: [
app,
"encodingFormat",
],
},
user: {
propDefinition: [
app,
"user",
],
},
},

async run({ $ }) {
const response = await this.app.createEmbeddings({
$,
data: {
dimensions: this.dimensions,
encoding_format: this.encodingFormat,
input: this.input,
model: this.embeddingModel,
user: this.user,
},
});
$.export("$summary", "Successfully created embedding");
return response;
},
};
4 changes: 1 addition & 3 deletions components/x_ai/actions/get-model/get-model.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "x_ai-get-model",
name: "Get Model",
description: "List all language and embedding models available. [See the documentation](https://docs.x.ai/api/endpoints#get-model)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand All @@ -21,9 +21,7 @@ export default {
$,
model: this.model,
});

$.export("$summary", `Successfully retrieved the '${this.model}' model`);

return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "x_ai-post-chat-completion",
name: "Post Chat Completion",
description: "Create a language model response for a chat conversation. [See the documentation](https://docs.x.ai/api/endpoints#chat-completions)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand All @@ -20,6 +20,66 @@ export default {
"message",
],
},
frequencyPenalty: {
propDefinition: [
app,
"frequencyPenalty",
],
},
logprobs: {
propDefinition: [
app,
"logprobs",
],
},
maxTokens: {
propDefinition: [
app,
"maxTokens",
],
},
n: {
propDefinition: [
app,
"n",
],
},
presencePenalty: {
propDefinition: [
app,
"presencePenalty",
],
},
seed: {
propDefinition: [
app,
"seed",
],
},
stream: {
propDefinition: [
app,
"stream",
],
},
temperature: {
propDefinition: [
app,
"temperature",
],
},
topP: {
propDefinition: [
app,
"topP",
],
},
user: {
propDefinition: [
app,
"user",
],
},
},

async run({ $ }) {
Expand All @@ -28,16 +88,24 @@ export default {
data: {
model: this.model,
messages: [
{
role: "user",
content: this.message,
{
role: "user",
content: this.message,
},
],
frequency_penalty: Number(this.frequencyPenalty),
logprobs: this.logprobs,
max_tokens: this.maxTokens,
n: this.n,
presence_penalty: Number(this.presencePenalty),
seed: this.seed,
stream: this.stream,
temperature: Number(this.temperature),
top_p: Number(this.topP),
user: this.user,
},
});

$.export("$summary", `Successfully sent message to the model '${this.model}'`);

return response;
},
};
88 changes: 85 additions & 3 deletions components/x_ai/actions/post-completion/post-completion.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "x_ai-post-completion",
name: "Post Completion",
description: "Create a language model response for a given prompt. [See the documentation](https://docs.x.ai/api/endpoints#completions)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand All @@ -20,6 +20,78 @@ export default {
"prompt",
],
},
echo: {
propDefinition: [
app,
"echo",
],
},
frequencyPenalty: {
propDefinition: [
app,
"frequencyPenalty",
],
},
logprobs: {
propDefinition: [
app,
"logprobs",
],
},
maxTokens: {
propDefinition: [
app,
"maxTokens",
],
},
n: {
propDefinition: [
app,
"n",
],
},
presencePenalty: {
propDefinition: [
app,
"presencePenalty",
],
},
seed: {
propDefinition: [
app,
"seed",
],
},
stream: {
propDefinition: [
app,
"stream",
],
},
suffix: {
propDefinition: [
app,
"suffix",
],
},
temperature: {
propDefinition: [
app,
"temperature",
],
},
topP: {
propDefinition: [
app,
"topP",
],
},
user: {
propDefinition: [
app,
"user",
],
},
},

async run({ $ }) {
Expand All @@ -28,11 +100,21 @@ export default {
data: {
model: this.model,
prompt: this.prompt,
echo: this.echo,
frequency_penalty: Number(this.frequencyPenalty),
logprobs: this.logprobs,
max_tokens: this.maxTokens,
n: this.n,
presence_penalty: Number(this.presencePenalty),
seed: this.seed,
stream: this.stream,
suffix: this.suffix,
temperature: Number(this.temperature),
top_p: Number(this.topP),
user: this.user,
},
});

$.export("$summary", `Successfully sent prompt to the model '${this.model}'`);

return response;
},
};
6 changes: 6 additions & 0 deletions components/x_ai/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
ENCODING_FORMATS: [
"float",
"base64",
],
};
4 changes: 2 additions & 2 deletions components/x_ai/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pipedream/x_ai",
"version": "0.1.0",
"description": "Pipedream X AI Components",
"version": "0.1.1",
"description": "Pipedream Chat Data Components",
"main": "x_ai.app.mjs",
"keywords": [
"pipedream",
Expand Down
Loading

0 comments on commit 63ac5ef

Please sign in to comment.