"# Applied-Advanced-RAG"
applied-advanced-rag's Introduction
applied-advanced-rag's People
Forkers
saniasawant03 heririta zaingz emehprincewill mdwoicke mahadih534 seeli-rag solnone robsongoncalves ashlinrajangabrielapplied-advanced-rag's Issues
ValidationError on output_parser = LineListOutputParser()
Hi, when I run this cell:
from langchain.chains import LLMChain
from langchain.output_parsers import PydanticOutputParser
from langchain.prompts import PromptTemplate
from pydantic import BaseModel, Field
query = "Do you offer vegetarian food?"
class LineList(BaseModel):
lines: list[str] = Field(description="Lines of text")
class LineListOutputParser(PydanticOutputParser):
def __init__(self) -> None:
super().__init__(pydantic_object=LineList)
def parse(self, text: str) -> list[str]:
lines = text.strip().split("\n")
return lines
output_parser = LineListOutputParser()
QUERY_PROMPT = PromptTemplate(
input_variables=["question"],
template="""You are an AI language model assistant. Your task is to generate five
different versions of the given user question to retrieve relevant documents from a vector
database. By generating multiple perspectives on the user question, your goal is to help
the user overcome some of the limitations of the distance-based similarity search.
Provide these alternative questions separated by newlines. Only provide the query, no numbering.
Original question: {question}""",
)
llm_chain = LLMChain(llm=llm, prompt=QUERY_PROMPT, output_parser=output_parser)
queries = llm_chain.invoke(query)
I have this error cell output:
{
"name": "ValidationError",
"message": "1 validation error for LineListOutputParser
pydantic_object
subclass of BaseModel expected (type=type_error.subclass; expected_class=BaseModel)",
"stack": "---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[23], line 21
17 lines = text.strip().split(\"\
\")
18 return lines
---> 21 output_parser = LineListOutputParser()
23 QUERY_PROMPT = PromptTemplate(
24 input_variables=[\"question\"],
25 template=\"\"\"You are an AI language model assistant. Your task is to generate five
(...)
30 Original question: {question}\"\"\",
31 )
33 llm_chain = LLMChain(llm=llm, prompt=QUERY_PROMPT, output_parser=output_parser)
Cell In[23], line 14, in LineListOutputParser.__init__(self)
13 def __init__(self) -> None:
---> 14 super().__init__(pydantic_object=LineList)
File ~/.local/lib/python3.10/site-packages/langchain_core/load/serializable.py:107, in Serializable.__init__(self, **kwargs)
106 def __init__(self, **kwargs: Any) -> None:
--> 107 super().__init__(**kwargs)
108 self._lc_kwargs = kwargs
File ~/.local/lib/python3.10/site-packages/pydantic/v1/main.py:341, in BaseModel.__init__(__pydantic_self__, **data)
339 values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
340 if validation_error:
--> 341 raise validation_error
342 try:
343 object_setattr(__pydantic_self__, '__dict__', values)
ValidationError: 1 validation error for LineListOutputParser
pydantic_object
subclass of BaseModel expected (type=type_error.subclass; expected_class=BaseModel)"
}
Do you know how should I fix this? Thanks.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.