WeaviateQueryError: Query call with protocol GRPC search failed

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

Any additional Information

Hi @Agam !!

Welcome to our community :hugs:

The issue is that while you have passed the OpenAI api key, you never specified what vectorizer and generative integration you want.

Here, this should be you collection creation code:

from weaviate.classes.config import Configure
client.collections.create(
    collection_name,
    vectorizer_config=Configure.Vectorizer.text2vec_openai(),
    generative_config=Configure.Generative.openai(),
    properties=[
        Property(name="page", data_type=DataType.INT),
        Property(name="text", data_type=DataType.TEXT),
    ],
)

Check here for this step in our Quickstart:

Let me know if this helps!

Thanks!

By the way, This error message doesn’t give much on the actual issue :joy:

We are aware :hear_no_evil:

This error message should improve in future versions.

Thanks!

Awesome, yeah the error was kind of cryptic, good to hear you are looking into improving the DX.

Now I’m getting:

    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for _CollectionConfigCreate
generative_config
  Input should be a valid dictionary or instance of _GenerativeConfigCreate [type=model_type, input_value=<function _Generative.openai at 0x7f47a346ca60>, input_type=function]

I tried following the tutorial, ended with this:

def create_collection(collection_name: str):
    client.collections.delete(collection_name)
    client.collections.create(
        collection_name,
        vectorizer_config=Configure.Vectorizer.text2vec_openai(),
        generative_config=Configure.Generative.openai,
        properties=[
            Property(name="text", data_type=DataType.TEXT),
            Property(name="page", data_type=DataType.INT),
        ],
    )

Ok your example was missing () for the open ai.
Now it works!

1 Like

That’s right!!

Glad we figured it out.

If you have any other issues, let us know!