Hey, I was trying a project on a different computer, and now I can't use
Query Engine with Pydantic Outputs
Here's my code :
class List(BaseModel):
"""
List of items.
"""
items: list[str]
vector_store = RedisVectorStore(
custom_schema={} # some complex schema I skip
redis_url=f"redis://{REDIS_HOST}:{REDIS_PORT}",
)
llm = OpenAI(model="gpt-3.5-turbo-0125", temperature=0.0, api_key=OPENAI_API_KEY)
embeddings_model = OpenAIEmbedding(api_key=OPENAI_API_KEY)
Settings.embed_model = embeddings_model
Settings.llm = llm
index = VectorStoreIndex.from_vector_store(vector_store=vector_store)
pydantic_query_engine = index.as_query_engine(output_cls=List, response_mode=ResponseMode.TREE_SUMMARIZE)
query: PydanticResponse = pydantic_query_engine.query("List 5 keywords describing the text.")
print(query.response.json())
It works perfectly well with classic queries 🤔