I recently set up a Weaviate Cloud Cluster using the instructions from the quick start manual.
The data has been imported successfully, and the client connection is functioning.
For the ask
function, I have implemented the following:
export async function question(collection: Collections, question: string) {
await client.graphql
.get()
.withClassName(collection)
.withAsk({ question })
.withFields('memberName _additional { answer { hasAnswer property result startPosition endPosition } }')
.withLimit(5)
.do()
}
question(Collections.TeamMember, 'Who has painting as a hobby?')
.then((result) => { console.log(result) });
Instead of returning Sarah Mitchell
, it returns undefined
. This was unexpected.
Additional information:
Schema
I manually created a schema in order to add `qna-openai` to the `moduleConfig` following the instructions provided here:
export async function addClassToSchema(classObject: object) {
const res = await client.schema.classCreator().withClass(classObject).do();
}
The class object:
{
"class": "TeamMember",
"vectorizer": "text2vec-openai",
"moduleConfig": {
"text2vec-openai": {},
"qna-openai": {
"model": "text-davinci-002",
"maxTokens": 16,
"temperature": 0.0,
"topP": 1,
"frequencyPenalty": 0.0,
"presencePenalty": 0.0
}
},
"properties": [
{
"name": "teamName",
"dataType": ["text"]
},
{
"name": "memberName",
"dataType": ["text"]
},
{
"name": "jobDescription",
"dataType": ["text"]
},
{
"name": "responsibilities",
"dataType": ["text"]
},
{
"name": "education",
"dataType": ["text"]
},
{
"name": "hobbies",
"dataType": ["text"]
}
]
}
Retrieving provides the following response:
{
// JSON Response Here
}
Objects
I then proceeded to import a list of members into the Weaviate instance.
export async function teamMembersImport() {
// JavaScript code for importing team members
}
A GET request to will return an array of objects containing member details.
{
// JSON Response Here
}