thomasjacob04 commited on
Commit
1ebc6cd
·
verified ·
1 Parent(s): 3c81ae5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -44
app.py CHANGED
@@ -99,47 +99,7 @@ rag_chain = (
99
  | StrOutputParser()
100
  )
101
 
102
- # return rag_chain.invoke(query)
103
-
104
- # Main function
105
- def main(pdf_path: str, query: str) -> str:
106
- # Use existing components for PDF processing and RAG
107
- loader = DoclingPDFLoader(file_path=pdf_path)
108
- text_splitter = RecursiveCharacterTextSplitter(
109
- chunk_size=1000,
110
- chunk_overlap=200,
111
- )
112
-
113
- docs = loader.load()
114
- splits = text_splitter.split_documents(docs)
115
-
116
- # Use the existing vectorstore
117
- vectorstore = Milvus.from_documents(
118
- splits,
119
- embeddings,
120
- connection_args={"uri": MILVUS_URI},
121
- index_params={
122
- "index_type": "IVF_FLAT",
123
- "metric_type": "L2",
124
- "params": {"nlist": 128}
125
- },
126
- drop_old=True,
127
- )
128
-
129
- # Use the existing RAG chain
130
- response = rag_chain.invoke(query)
131
- return response
132
-
133
- if __name__ == "__main__":
134
- # Initialize Gradio interface
135
- def ask_question(question: str) -> str:
136
- return main("vol1.pdf", question)
137
-
138
- iface = gr.Interface(
139
- fn=ask_question,
140
- inputs="text",
141
- outputs="text",
142
- title="PDF Question Answering",
143
- description="Ask questions about the PDF content"
144
- )
145
- iface.launch()
 
99
  | StrOutputParser()
100
  )
101
 
102
+ rag_chain.invoke("can you explain the subject matter to a primary school student?")
103
+
104
+
105
+