-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] weaviate #10916 #18377
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
[Components] weaviate #10916 #18377
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import app from "../../weaviate.app.mjs"; | ||
|
||
export default { | ||
key: "weaviate-create-class", | ||
name: "Create Class", | ||
description: "Create a new class in Weaviate. [See the documentation](https://docs.weaviate.io/weaviate/api/rest#tag/schema/post/schema)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
className: { | ||
propDefinition: [ | ||
app, | ||
"className", | ||
], | ||
}, | ||
properties: { | ||
propDefinition: [ | ||
app, | ||
"properties", | ||
], | ||
}, | ||
description: { | ||
propDefinition: [ | ||
app, | ||
"description", | ||
], | ||
}, | ||
multiTenancyEnabled: { | ||
propDefinition: [ | ||
app, | ||
"multiTenancyEnabled", | ||
], | ||
}, | ||
vectorIndexType: { | ||
propDefinition: [ | ||
app, | ||
"vectorIndexType", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const parsedProperties = this.properties?.map((p) => JSON.parse(p)) || []; | ||
const response = await this.app.createClass({ | ||
$, | ||
data: { | ||
class: this.className, | ||
description: this.description, | ||
vectorizer: this.vectorizer, | ||
multiTenancyConfig: { | ||
enabled: this.multiTenancyEnabled, | ||
}, | ||
vectorIndexType: this.vectorIndexType, | ||
properties: parsedProperties, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully sent the request to create a new class"); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import app from "../../weaviate.app.mjs"; | ||
|
||
export default { | ||
key: "weaviate-delete-class", | ||
name: "Delete Class", | ||
description: "Delete a class from Weaviate. [See the documentation](https://docs.weaviate.io/weaviate/api/rest#tag/schema/delete/schema/{className})", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
classId: { | ||
propDefinition: [ | ||
app, | ||
"classId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.deleteClass({ | ||
$, | ||
classId: this.classId, | ||
}); | ||
$.export("$summary", "Successfully deleted the class named " + this.classId); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import app from "../../weaviate.app.mjs"; | ||
|
||
export default { | ||
key: "weaviate-get-schema", | ||
name: "Get Schema", | ||
description: "Get schema from Weaviate. [See the documentation](https://docs.weaviate.io/weaviate/api/rest#tag/schema/get/schema)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getSchema({ | ||
$, | ||
}); | ||
$.export("$summary", "Successfully retrieved the current database schema"); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
VECTOR_TYPES: [ | ||
"hnsw", | ||
"flat", | ||
], | ||
}; | ||
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainConsider verifying if the vector types list is complete. The constants module correctly exports the vector types. However, ensure these are all the supported vector index types in Weaviate. 🌐 Web query:
💡 Result: Weaviate supports three vector index types: hnsw, flat, and dynamic. (docs.weaviate.io) Citations: Include 'dynamic' in VECTOR_TYPES export. Weaviate supports "hnsw", "flat", and "dynamic" — update components/weaviate/common/constants.mjs (lines 1–6) to add "dynamic" to VECTOR_TYPES. 🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/weaviate", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Weaviate Components", | ||
"main": "weaviate.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.1.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,93 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import constants from "./common/constants.mjs"; | ||
|
||
export default { | ||
type: "app", | ||
app: "weaviate", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
className: { | ||
type: "string", | ||
label: "Class Name", | ||
description: "The name of the class to create", | ||
}, | ||
properties: { | ||
type: "string[]", | ||
label: "Properties", | ||
description: "The properties of the class. Each item must be a JSON object string, e.g.: `{ \"name\": \"title\", \"dataType\": [\"text\"], \"description\": \"Title of the object\" }`", | ||
}, | ||
description: { | ||
type: "string", | ||
label: "Description", | ||
description: "Optional description of the class", | ||
optional: true, | ||
}, | ||
multiTenancyEnabled: { | ||
type: "boolean", | ||
label: "Multi-tenancy Enabled", | ||
description: "Set to `true` to enable multi-tenancy for this class", | ||
optional: true, | ||
}, | ||
vectorIndexType: { | ||
type: "string", | ||
label: "Vector Index Type", | ||
description: "Type of vector index to use", | ||
optional: true, | ||
options: constants.VECTOR_TYPES, | ||
}, | ||
classId: { | ||
type: "string", | ||
label: "Class Name", | ||
description: "Name of the Class", | ||
async options() { | ||
const response = await this.getSchema(); | ||
return response.classes.map(({ class: className }) => ({ | ||
value: className, | ||
label: className, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return `https://${this.$auth.cluster_url}`; | ||
}, | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, | ||
path, | ||
headers, | ||
...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
url: this._baseUrl() + path, | ||
headers: { | ||
Authorization: `Bearer ${this.$auth.api_key}`, | ||
...headers, | ||
}, | ||
}); | ||
}, | ||
async createClass(args = {}) { | ||
return this._makeRequest({ | ||
path: "/v1/schema", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async deleteClass({ | ||
classId, ...args | ||
}) { | ||
return this._makeRequest({ | ||
path: `/v1/schema/${classId}`, | ||
method: "delete", | ||
...args, | ||
}); | ||
}, | ||
async getSchema(args = {}) { | ||
return this._makeRequest({ | ||
path: "/v1/schema", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden
properties
parsing to avoid unhandled JSON.parse errors and accept objects.Invalid JSON will currently throw and fail the step; also breaks if an element is already an object.
📝 Committable suggestion
🤖 Prompt for AI Agents