Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
feat(collection): introduce TASK_UNION, TASK_INTERSECTION and TASK_DI…
Browse files Browse the repository at this point in the history
…FFERENCE (#357)

Because

- We want to provide set operations.

This commit

- Introduces new set operations: `TASK_UNION`, `TASK_INTERSECTION`, and
`TASK_DIFFERENCE`.
  • Loading branch information
donch1989 authored Sep 23, 2024
1 parent 315ef6c commit 1b68dad
Show file tree
Hide file tree
Showing 7 changed files with 411 additions and 15 deletions.
24 changes: 12 additions & 12 deletions ai/universalai/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ Generate response base on conversation input
<details>
<summary> Input Objects in Chat</summary>

<h4 id="chat-input-parameter">Input Parameter</h4>

Input parameter

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
| Max new tokens | `max-tokens` | integer | The maximum number of tokens for model to generate |
| Number of choices | `n` | integer | How many chat completion choices to generate for each input message. |
| Seed | `seed` | integer | The seed, default is 0 |
| Stream | `stream` | boolean | If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available. |
| Temperature | `temperature` | number | The temperature for sampling |
| Top P | `top-p` | number | An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. |
<h4 id="chat-chat-data">Chat Data</h4>

Input data
Expand All @@ -80,6 +68,18 @@ List of chat messages
| [Content](#chat-content) | `content` | array | The message content |
| Name | `name` | string | An optional name for the participant. Provides the model information to differentiate between participants of the same role. |
| Role | `role` | string | The message role, i.e. 'system', 'user' or 'assistant' <br/><details><summary><strong>Enum values</strong></summary><ul><li>`system`</li><li>`user`</li><li>`assistant`</li></ul></details> |
<h4 id="chat-input-parameter">Input Parameter</h4>

Input parameter

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
| Max new tokens | `max-tokens` | integer | The maximum number of tokens for model to generate |
| Number of choices | `n` | integer | How many chat completion choices to generate for each input message. |
| Seed | `seed` | integer | The seed, default is 0 |
| Stream | `stream` | boolean | If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available. |
| Temperature | `temperature` | number | The temperature for sampling |
| Top P | `top-p` | number | An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both. |
</details>


Expand Down
55 changes: 55 additions & 0 deletions generic/collection/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The Collection component is a generic component that allows users to manipulate
It can carry out the following tasks:
- [Assign](#assign)
- [Append Array](#append-array)
- [Union](#union)
- [Intersection](#intersection)
- [Difference](#difference)

## Release Stage

Expand Down Expand Up @@ -56,3 +59,55 @@ Add data to the end of an array.
| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Array | `array` | array | A updated array with the specified data appended to the end of it. |

### Union

Find the union of the sets

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_UNION` |
| Array (required) | `sets` | array | Specify the sets you want to union. |





| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Array | `set` | array | The union set. |

### Intersection

Find the intersection of the sets

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_INTERSECTION` |
| Array (required) | `sets` | array | Specify the sets you want to intersect. |





| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Array | `set` | array | The intersection set. |

### Difference

Find the difference between the two sets, i.e. `set-a` \ `set-b`, identifying the elements that are in `set-a` but not in `set-b`.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_DIFFERENCE` |
| Array (required) | `set-a` | array | Specify the set-a. |
| Array (required) | `set-b` | array | Specify the set-b. |





| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Array | `set` | array | The difference set. |
5 changes: 4 additions & 1 deletion generic/collection/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"availableTasks": [
"TASK_ASSIGN",
"TASK_APPEND_ARRAY"
"TASK_APPEND_ARRAY",
"TASK_UNION",
"TASK_INTERSECTION",
"TASK_DIFFERENCE"
],
"custom": false,
"documentationUrl": "https://www.instill.tech/docs/component/generic/collection",
Expand Down
190 changes: 190 additions & 0 deletions generic/collection/v0/config/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,195 @@
"title": "Output",
"type": "object"
}
},
"TASK_UNION": {
"instillShortDescription": "Find the union of the sets",
"input": {
"description": "Input",
"instillEditOnNodeFields": [
"sets"
],
"instillUIOrder": 0,
"properties": {
"sets": {
"description": "Specify the sets you want to union.",
"instillAcceptFormats": [
"array:array:*"
],
"instillUIMultiline": true,
"instillUIOrder": 0,
"instillUpstreamTypes": [
"value",
"reference",
"template"
],
"items": {},
"required": [],
"title": "Array",
"type": "array"
}
},
"required": [
"sets"
],
"title": "Input",
"type": "object"
},
"output": {
"description": "Output",
"instillEditOnNodeFields": [
"set"
],
"instillUIOrder": 0,
"properties": {
"set": {
"description": "The union set.",
"instillEditOnNodeFields": [],
"instillFormat": "array:*",
"instillUIOrder": 0,
"required": [],
"title": "Array",
"type": "array"
}
},
"required": [
"set"
],
"title": "Output",
"type": "object"
}
},
"TASK_INTERSECTION": {
"instillShortDescription": "Find the intersection of the sets",
"input": {
"description": "Input",
"instillEditOnNodeFields": [
"sets"
],
"instillUIOrder": 0,
"properties": {
"sets": {
"description": "Specify the sets you want to intersect.",
"instillAcceptFormats": [
"array:array:*"
],
"instillUIMultiline": true,
"instillUIOrder": 0,
"instillUpstreamTypes": [
"value",
"reference",
"template"
],
"items": {},
"required": [],
"title": "Array",
"type": "array"
}
},
"required": [
"sets"
],
"title": "Input",
"type": "object"
},
"output": {
"description": "Output",
"instillEditOnNodeFields": [
"set"
],
"instillUIOrder": 0,
"properties": {
"set": {
"description": "The intersection set.",
"instillEditOnNodeFields": [],
"instillFormat": "array:*",
"instillUIOrder": 0,
"required": [],
"title": "Array",
"type": "array"
}
},
"required": [
"set"
],
"title": "Output",
"type": "object"
}
},
"TASK_DIFFERENCE": {
"instillShortDescription": "Find the difference between the two sets, i.e. `set-a` \\ `set-b`, identifying the elements that are in `set-a` but not in `set-b`.",
"input": {
"description": "Input",
"instillEditOnNodeFields": [
"set-a",
"set-b"
],
"instillUIOrder": 0,
"properties": {
"set-a": {
"description": "Specify the set-a.",
"instillAcceptFormats": [
"array:*"
],
"instillUIMultiline": true,
"instillUIOrder": 0,
"instillUpstreamTypes": [
"value",
"reference",
"template"
],
"items": {},
"required": [],
"title": "Array",
"type": "array"
},
"set-b": {
"description": "Specify the set-b.",
"instillAcceptFormats": [
"array:*"
],
"instillUIMultiline": true,
"instillUIOrder": 0,
"instillUpstreamTypes": [
"value",
"reference",
"template"
],
"items": {},
"required": [],
"title": "Array",
"type": "array"
}
},
"required": [
"set-a",
"set-b"
],
"title": "Input",
"type": "object"
},
"output": {
"description": "Output",
"instillEditOnNodeFields": [
"set"
],
"instillUIOrder": 0,
"properties": {
"set": {
"description": "The difference set.",
"instillEditOnNodeFields": [],
"instillFormat": "array:*",
"instillUIOrder": 0,
"required": [],
"title": "Array",
"type": "array"
}
},
"required": [
"set"
],
"title": "Output",
"type": "object"
}
}
}
Loading

0 comments on commit 1b68dad

Please sign in to comment.