Find answers from the community

Updated 6 months ago

```py

At a glance
Plain Text
from qdrant_client import QdrantClient, models
from llama_index.vector_stores.qdrant import QdrantVectorStore
from llama_index.core import Settings, VectorStoreIndex
from llama_index.llms.ollama import Ollama
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.core.retrievers import VectorIndexRetriever

client = QdrantClient(url='http://localhost:6333')

# Settings for the RAG application
Settings.llm = Ollama('llama3.1', request_timeout=10000.0)
Settings.embed_model = HuggingFaceEmbedding(model_name='sentence-transformers/all-MiniLM-L6-v2') 

# Creating vector store from existing qdrant collection 
vector_store = QdrantVectorStore(client=client, collection_name='demo_collection')

# Creating index from loaded store 
index = VectorStoreIndex.from_vector_store(vector_store=vector_store)

query_engine = index.as_query_engine()

while True:
    user_query = input()

    if user_query == '/bye':
        break

    response = query_engine.query(
        "Which institution was recognized as the top polytechnic college in Rajasthan for three consecutive years?"
    )
    print(response)

I am following tutorial and this code throws an error,
saying input must be a valid string.

Here is the stack trace.
Plain Text
self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for TextNode
text
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.8/v/string_type
W
A
14 comments
You need to update llama-index lib, try with pip install -U llama-index
If possible update all the deps or install in a fresh new env. version 0.11 did pydantic upgrade from 1 to version 2.x
no,
I've taken a look at the underlying implementation,

It is expecting a text field in its payload.
Try updating the deps
My payload has field named description ,
upserted the points by changing description key to text in the payload
llama index is using TextNode and is expecting a text key in payload of every vector.
Which was missing in my impl.
I see, lol my bad πŸ˜† I saw pydantic error my mind went straight to version upgrade
Since llama_index is made for working with Multi-Modal RAG's.
TextNode might be a must and should impl in the process
Yes sir but not because it works with Multi-modal. TextNode is the base class which gives shape to Nodes and Document etc.

text is an imp part of this class as we use this text to create embeddings , show text from the nodes, allow user to create own document object using text.
Thank you so much
Add a reply
Sign up and join the conversation on Discord