Update app.py
Browse files
app.py
CHANGED
@@ -39,11 +39,11 @@ def text_extract(file):
|
|
39 |
for page_num in range(num_pages):
|
40 |
page = pdf_reader.pages[page_num]
|
41 |
text += page.extract_text() or ""
|
42 |
-
text_splitter = text_splitter_function(text)
|
43 |
-
embeddings = GooglePalmEmbeddings(google_api_key=google_api)
|
44 |
-
print(embeddings)
|
45 |
-
db = FAISS.from_texts(text_splitter, embeddings)
|
46 |
-
print(db)
|
47 |
# retriever = db.as_retriever(search_type="similarity", search_kwargs={"k": 2})
|
48 |
# llm=GooglePalm(google_api_key=google_api)
|
49 |
# qa = RetrievalQA.from_chain_type(
|
@@ -53,7 +53,11 @@ def text_extract(file):
|
|
53 |
# print("FitBot:",result1['result'])
|
54 |
# Split extracted text into chunks
|
55 |
# result = helper(text_splitter) # Call helper to process text chunks
|
56 |
-
|
|
|
|
|
|
|
|
|
57 |
|
58 |
# Define Gradio interface
|
59 |
with gr.Blocks() as demo:
|
|
|
39 |
for page_num in range(num_pages):
|
40 |
page = pdf_reader.pages[page_num]
|
41 |
text += page.extract_text() or ""
|
42 |
+
# text_splitter = text_splitter_function(text)
|
43 |
+
# embeddings = GooglePalmEmbeddings(google_api_key=google_api)
|
44 |
+
# print(embeddings)
|
45 |
+
# db = FAISS.from_texts(text_splitter, embeddings)
|
46 |
+
# print(db)
|
47 |
# retriever = db.as_retriever(search_type="similarity", search_kwargs={"k": 2})
|
48 |
# llm=GooglePalm(google_api_key=google_api)
|
49 |
# qa = RetrievalQA.from_chain_type(
|
|
|
53 |
# print("FitBot:",result1['result'])
|
54 |
# Split extracted text into chunks
|
55 |
# result = helper(text_splitter) # Call helper to process text chunks
|
56 |
+
client = genai.Client(api_key="AIzaSyBaY8zx4ak0t4TkBp28lL2hLqREzlN_Mb0")
|
57 |
+
response = client.models.generate_content(
|
58 |
+
model="gemini-2.0-flash", contents=f"you will be given the input data you have to answer the question according to the user input : {text}"
|
59 |
+
)
|
60 |
+
return print(response.text)
|
61 |
|
62 |
# Define Gradio interface
|
63 |
with gr.Blocks() as demo:
|