Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] x AI - model actions after OpenAI chat actions #14753 #14868

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the version should be 0.0.1

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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"version": "0.1.1",
"version": "0.2.0",

since you are adding a new component

"description": "Pipedream Chat Data Components",
"main": "x_ai.app.mjs",
"keywords": [
"pipedream",
Expand Down
Loading
Loading