Description
from dotenv import load_dotenv
load_dotenv()
client = weaviate.connect_to_weaviate_cloud(
cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your Weaviate Cloud URL
auth_credentials=weaviate.auth.AuthApiKey(
os.getenv("WEAVIATE_KEY")
), # Replace with your Weaviate Cloud key
headers={
"X-OpenAI-Api-key": os.getenv("OPENAI_APIKEY")
}, # Replace with your OpenAI API key
)
def create_collection(collection_name: str):
client.collections.delete(collection_name)
client.collections.create(
collection_name,
properties=[
Property(name="page", data_type=DataType.INT),
Property(name="text", data_type=DataType.TEXT),
],
)
def store_new_doc(collection_name: str):
extracted_text = [
{
"text": "Some test about dogs.",
"page": 0,
},
{
"text": "Test some text about cats.",
"page": 1,
},
]
print(extracted_text)
collection = client.collections.get(collection_name)
with collection.batch.dynamic() as batch:
for data_row in extracted_text:
batch.add_object(
properties=data_row,
)
def query(collection_name: str, query_text: str):
collection = client.collections.get(collection_name)
response = collection.query.near_text(
query=query_text,
limit=3,
return_metadata=MetadataQuery(score=True),
)
for o in response.objects:
print(o.properties)
print(o.metadata.score)
if __name__ == "__main__":
create_collection("Test")
store_new_doc("Test")
query("Test", "What animal says meow?")
And I get:
raise WeaviateQueryError(e.details(), "GRPC search") # pyright: ignore
weaviate.exceptions.WeaviateQueryError: Query call with protocol GRPC search failed with message panic occurred: ValidateParam was called without any known params present.
Server Setup Information
- Weaviate Server Version: Cloud
- Deployment Method:
- Multi Node? Number of Running Nodes: 1
- Client Language and Version: EN, 4.6.4
- Multitenancy?: Nope