rocioadlc commited on
Commit
cee59f8
Β·
verified Β·
1 Parent(s): 3af3f0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -104,12 +104,22 @@ vectordb = Chroma.from_documents(
104
  # define retriever
105
  retriever = vectordb.as_retriever(search_kwargs={"k": 2}, search_type="mmr")
106
 
107
- class FinalAnswer(BaseModel):
108
  question: str = Field(description="the original question")
109
  answer: str = Field(description="the extracted answer")
110
 
111
- # Assuming you have a parser for the FinalAnswer class
112
- parser = PydanticOutputParser(pydantic_object=FinalAnswer)
 
 
 
 
 
 
 
 
 
 
113
 
114
  template = """
115
  Your name is Greta and you are a recycling chatbot with the objective to anwer questions from user in English or Spanish /
 
104
  # define retriever
105
  retriever = vectordb.as_retriever(search_kwargs={"k": 2}, search_type="mmr")
106
 
107
+ class Answer(BaseModel):
108
  question: str = Field(description="the original question")
109
  answer: str = Field(description="the extracted answer")
110
 
111
+ # Set up a PydanticOutputParser
112
+ parser = PydanticOutputParser(pydantic_object=Answer)
113
+
114
+
115
+ parser = PydanticOutputParser(pydantic_object=Answer)
116
+
117
+ # Create a prompt with format instructions
118
+ prompt = PromptTemplate(
119
+ template="Answer the user query.\n{format_instructions}\n{query}\n",
120
+ input_variables=["query"],
121
+ partial_variables={"format_instructions": parser.get_format_instructions()},
122
+ )
123
 
124
  template = """
125
  Your name is Greta and you are a recycling chatbot with the objective to anwer questions from user in English or Spanish /