Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import os
|
2 |
from langchain_core.prompts import PromptTemplate
|
3 |
-
from langchain.chains.question_answering import load_qa_chain
|
4 |
from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser
|
5 |
from langchain_community.document_loaders import PyPDFLoader
|
6 |
import google.generativeai as genai
|
@@ -42,19 +41,13 @@ def initialize(pdf_file, question):
|
|
42 |
# Load the GeminiPro model
|
43 |
model = genai.GenerativeModel('gemini-pro')
|
44 |
|
45 |
-
#
|
46 |
-
print(type(model))
|
47 |
-
print(dir(model)) # List attributes and methods
|
48 |
|
49 |
-
#
|
50 |
-
|
51 |
-
raise Exception("Your LLM object might not have a text generation method!")
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
# Extract the answer
|
57 |
-
generated_answer = stuff_answer['output_text']
|
58 |
|
59 |
return generated_answer
|
60 |
else:
|
|
|
1 |
import os
|
2 |
from langchain_core.prompts import PromptTemplate
|
|
|
3 |
from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser
|
4 |
from langchain_community.document_loaders import PyPDFLoader
|
5 |
import google.generativeai as genai
|
|
|
41 |
# Load the GeminiPro model
|
42 |
model = genai.GenerativeModel('gemini-pro')
|
43 |
|
44 |
+
# ... rest of your code for processing context and question
|
|
|
|
|
45 |
|
46 |
+
# Generate answer using GeminiPro's predict method (replace with the appropriate method)
|
47 |
+
generated_answer = model.predict(inputs=prompt) # Assuming a 'predict' method
|
|
|
48 |
|
49 |
+
# Extract the answer (parse the output from 'predict')
|
50 |
+
# ... (implementation depends on the model's output format)
|
|
|
|
|
|
|
51 |
|
52 |
return generated_answer
|
53 |
else:
|