-
Notifications
You must be signed in to change notification settings - Fork 5.5k
OpenAI - Vector Store and Vector Store Files actions #14435
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
components/openai/actions/create-vector-store-file/create-vector-store-file.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import openai from "../../openai.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "openai-create-vector-store-file", | ||
| name: "Create Vector Store File", | ||
| description: "Create a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/createFile)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| openai, | ||
| vectorStoreId: { | ||
| propDefinition: [ | ||
| openai, | ||
| "vectorStoreId", | ||
| ], | ||
| }, | ||
| fileId: { | ||
| propDefinition: [ | ||
| openai, | ||
| "fileId", | ||
| ], | ||
| }, | ||
| chunkingStrategy: { | ||
| type: "string", | ||
| label: "Chunking Strategy", | ||
| description: "The chunking strategy used to chunk the file", | ||
| options: [ | ||
| "auto", | ||
| "static", | ||
| ], | ||
| optional: true, | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| additionalProps() { | ||
| const props = {}; | ||
|
|
||
| if (this?.chunkingStrategy === "static") { | ||
| props.maxChunkSizeTokens = { | ||
| type: "integer", | ||
| label: "Max Chunk Size Tokens", | ||
| description: "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.", | ||
| default: 800, | ||
| optional: true, | ||
| }; | ||
| props.chunkOverlapTokens = { | ||
| type: "integer", | ||
| label: "Chunk Overlap Tokens", | ||
| description: "The number of tokens that overlap between chunks. The default value is `400`. Note that the overlap must not exceed half of max_chunk_size_tokens.", | ||
| default: 400, | ||
| optional: true, | ||
| }; | ||
| } | ||
|
|
||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.openai.createVectorStoreFile({ | ||
| $, | ||
| vectorStoreId: this.vectorStoreId, | ||
| data: { | ||
| file_id: this.fileId, | ||
| chunking_strategy: this.chunkingStrategy && { | ||
| type: this.chunkingStrategy, | ||
| static: this.chunkingStrategy === "static" | ||
| ? { | ||
| max_chunk_size_tokens: this.maxChunkSizeTokens, | ||
| chunk_overlap_tokens: this.chunkOverlapTokens, | ||
| } | ||
| : undefined, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created vector store file with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
103 changes: 103 additions & 0 deletions
103
components/openai/actions/create-vector-store/create-vector-store.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import openai from "../../openai.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "openai-create-vector-store", | ||
| name: "Create Vector Store", | ||
| description: "Create a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/create)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| openai, | ||
| fileIds: { | ||
| propDefinition: [ | ||
| openai, | ||
| "fileId", | ||
| ], | ||
| type: "string[]", | ||
| label: "File IDs", | ||
| description: "An array of File IDs that the vector store should use", | ||
| optional: true, | ||
| reloadProps: true, | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Name of the vector store", | ||
| optional: true, | ||
| }, | ||
| expiryDays: { | ||
| type: "integer", | ||
| label: "Expiration Days", | ||
| description: "The number of days after the `last_active_at` time that the vector store will expire", | ||
| optional: true, | ||
| }, | ||
| metadata: { | ||
| type: "object", | ||
| label: "Metadata", | ||
| description: "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| additionalProps() { | ||
| const props = {}; | ||
| if (!this.fileIds?.length) { | ||
| return props; | ||
| } | ||
|
|
||
| props.chunkingStrategy = { | ||
| type: "string", | ||
| label: "Chunking Strategy", | ||
| description: "The chunking strategy used to chunk the file(s)", | ||
| options: [ | ||
| "auto", | ||
| "static", | ||
| ], | ||
| optional: true, | ||
| reloadProps: true, | ||
| }; | ||
|
|
||
| if (this?.chunkingStrategy === "static") { | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| props.maxChunkSizeTokens = { | ||
| type: "integer", | ||
| label: "Max Chunk Size Tokens", | ||
| description: "The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.", | ||
| default: 800, | ||
| optional: true, | ||
| }; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| props.chunkOverlapTokens = { | ||
| type: "integer", | ||
| label: "Chunk Overlap Tokens", | ||
| description: "The number of tokens that overlap between chunks. The default value is `400`. Note that the overlap must not exceed half of max_chunk_size_tokens.", | ||
| default: 400, | ||
| optional: true, | ||
| }; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.openai.createVectorStore({ | ||
| $, | ||
| data: { | ||
| file_ids: this.fileIds, | ||
| name: this.name, | ||
| expires_after: this.expiryDays && { | ||
| anchor: "last_active_at", | ||
| days: this.expiryDays, | ||
| }, | ||
| chunking_strategy: this.chunkingStrategy && { | ||
| type: this.chunkingStrategy, | ||
| static: this.chunkingStrategy === "static" | ||
| ? { | ||
| max_chunk_size_tokens: this.maxChunkSizeTokens, | ||
| chunk_overlap_tokens: this.chunkOverlapTokens, | ||
| } | ||
| : undefined, | ||
| }, | ||
| metadata: this.metadata, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created vector store with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
components/openai/actions/delete-vector-store-file/delete-vector-store-file.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import openai from "../../openai.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "openai-delete-vector-store-file", | ||
| name: "Delete Vector Store File", | ||
| description: "Deletes a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/deleteFile)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| openai, | ||
| vectorStoreId: { | ||
| propDefinition: [ | ||
| openai, | ||
| "vectorStoreId", | ||
| ], | ||
| }, | ||
| vectorStoreFileId: { | ||
| propDefinition: [ | ||
| openai, | ||
| "vectorStoreFileId", | ||
| (c) => ({ | ||
| vectorStoreId: c.vectorStoreId, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.openai.deleteVectorStoreFile({ | ||
| $, | ||
| vectorStoreId: this.vectorStoreId, | ||
| vectorStoreFileId: this.vectorStoreFileId, | ||
| }); | ||
| $.export("$summary", `Successfully deleted vector store file with ID: ${this.vectorStoreFileId}`); | ||
| return response; | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
26 changes: 26 additions & 0 deletions
26
components/openai/actions/delete-vector-store/delete-vector-store.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import openai from "../../openai.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "openai-delete-vector-store", | ||
| name: "Delete Vector Store", | ||
| description: "Delete a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/delete)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| openai, | ||
| vectorStoreId: { | ||
| propDefinition: [ | ||
| openai, | ||
| "vectorStoreId", | ||
| ], | ||
| }, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async run({ $ }) { | ||
| const response = await this.openai.deleteVectorStore({ | ||
| $, | ||
| vectorStoreId: this.vectorStoreId, | ||
| }); | ||
| $.export("$summary", `Successfully deleted vector store with ID: ${this.vectorStoreId}`); | ||
| return response; | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.