# Schema for DSPY

**URL:** <https://forum.weaviate.io/t/schema-for-dspy/1656>\
**Category:** Support\
**Tags:** wcs\
**Created:** [March 9, 2024, 1:06pm UTC](https://forum.weaviate.io/t/schema-for-dspy/1656 "2024-03-09T13:06:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EnkiEnil](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/enkienil/32/1092_2.png) [@EnkiEnil](https://forum.weaviate.io/u/EnkiEnil)\
**Post date:** [March 9, 2024, 1:06pm UTC](https://forum.weaviate.io/t/schema-for-dspy/1656/1 "2024-03-09T13:06:00Z")

</div>

Following the steps from 1.[Getting-Started-with-RAG-in-DSPy.ipynb](https://github.com/weaviate/recipes/blob/main/integrations/dspy/1.Getting-Started-with-RAG-in-DSPy.ipynb), unable to execute:

```auto
test_example = dspy.Example(question="What do cross encoders do?")

test_pred = dspy.Example(answer="They re-rank documents.")

type(llm_metric(test_example, test_pred))

```

Created a schema class that is based on the data, question and answer:

```auto
class_obj = {
    "class": "DSPY",
    "properties": [
        {
            "name": "data",
            "dataType": ["text"],
            # "indexInverted": True 
        },
        {
            "name": "question",
            "dataType": ["text"],
            # "indexInverted": True  
        },
        {
            "name": "answer",
            "dataType": ["text"],
            # "indexInverted": True 
        }
    ],
    "vectorizer": "text2vec-openai",
    "moduleConfig": {
        "text2vec-openai": {},
        "generative-openai": {}  
    }
}

weaviate_client.schema.create_class(class_obj)

```

###Error start:###

```auto
---> 79 results = results["data"]["Get"][self._weaviate_collection_name]
     80 parsed_results = [result["content"] for result in results]
     81 passages.extend(dotdict({"long_text": d}) for d in parsed_results)

KeyError: 'data'

```

###Error end:###

### Server Setup Information

- Weaviate Server Version: 3.26.2
- Deployment Method: Cloud
- Multi Node? Number of Running Nodes: 1
- Client Language and Version: en

New to weaviate, trying to follow the cookbook on weaviate/dspy to start using it within our app. I think I am missing a step on preparing the db within weaviate before I can follow the cookbook. Any guidance is appreciated, thank you

---

<div class="post-metadata">

**Author:** ![CShorten](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/cshorten/32/102_2.png) [@CShorten](https://forum.weaviate.io/u/CShorten)\
**Post date:** [March 9, 2024, 3:23pm UTC](https://forum.weaviate.io/t/schema-for-dspy/1656/2 "2024-03-09T15:23:38Z")

</div>

Hey @EnkiEnil, happy to help! Can you please show me the code for how you initialize the WeaviateRM? If you don’t explicitly pass in a `weaviate_collection_text_key` it will default to “content”, which I see isn’t in your schema so that is most likely the problem with the Weaviate query.

---

<div class="post-metadata">

**Author:** ![thiagobluhm](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/thiagobluhm/32/1356_2.png) [@thiagobluhm](https://forum.weaviate.io/u/thiagobluhm)\
**Post date:** [April 18, 2024, 10:56pm UTC](https://forum.weaviate.io/t/schema-for-dspy/1656/3 "2024-04-18T22:56:38Z")

</div>

Hello @CShorten, thanks for the response.

After this, I figured out how to explicitly define this argument:

```auto
rm = weaviate_client.schema.get()['classes'][0]['class']
retriever_model = WeaviateRM( rm , weaviate_client = weaviate_client, 
                                   #weaviate_collection_name=" ??? ",
                                   weaviate_collection_text_key="yourOwnTextProperty")

```

Note: What is `weaviate_collection_name` ? If I pass this name as a model property in the node name, it returns an error.
