Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -34,12 +34,10 @@ from langchain.prompts.prompt import PromptTemplate
|
|
34 |
from langchain.prompts.chat import ChatPromptTemplate, SystemMessagePromptTemplate
|
35 |
from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate, MessagesPlaceholder
|
36 |
from langchain.document_loaders import PyPDFDirectoryLoader
|
37 |
-
from pydantic import BaseModel, Field
|
38 |
from langchain.output_parsers import PydanticOutputParser
|
39 |
from langchain_community.llms import HuggingFaceHub
|
40 |
from langchain_community.document_loaders import WebBaseLoader
|
41 |
-
|
42 |
-
from langchain.pydantic_v1 import BaseModel
|
43 |
import shutil
|
44 |
|
45 |
|
@@ -98,8 +96,8 @@ vectordb = Chroma.from_documents(
|
|
98 |
retriever = vectordb.as_retriever(search_kwargs={"k": 2}, search_type="mmr")
|
99 |
|
100 |
class FinalAnswer(BaseModel):
|
101 |
-
question: str = Field(
|
102 |
-
answer: str = Field(
|
103 |
|
104 |
# Assuming you have a parser for the FinalAnswer class
|
105 |
parser = PydanticOutputParser(pydantic_object=FinalAnswer)
|
|
|
34 |
from langchain.prompts.chat import ChatPromptTemplate, SystemMessagePromptTemplate
|
35 |
from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate, MessagesPlaceholder
|
36 |
from langchain.document_loaders import PyPDFDirectoryLoader
|
|
|
37 |
from langchain.output_parsers import PydanticOutputParser
|
38 |
from langchain_community.llms import HuggingFaceHub
|
39 |
from langchain_community.document_loaders import WebBaseLoader
|
40 |
+
from pydantic import BaseModel, Field
|
|
|
41 |
import shutil
|
42 |
|
43 |
|
|
|
96 |
retriever = vectordb.as_retriever(search_kwargs={"k": 2}, search_type="mmr")
|
97 |
|
98 |
class FinalAnswer(BaseModel):
|
99 |
+
question: str = Field()
|
100 |
+
answer: str = Field()
|
101 |
|
102 |
# Assuming you have a parser for the FinalAnswer class
|
103 |
parser = PydanticOutputParser(pydantic_object=FinalAnswer)
|