Update app.py
Browse files
app.py
CHANGED
@@ -62,6 +62,17 @@ def bot(
|
|
62 |
"GOOGLE_API_KEY is not set. "
|
63 |
"Please follow the instructions in the README to set it up.")
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
text_prompt = chatbot[-1][0]
|
66 |
genai.configure(api_key=google_key)
|
67 |
generation_config = genai.types.GenerationConfig(
|
|
|
62 |
"GOOGLE_API_KEY is not set. "
|
63 |
"Please follow the instructions in the README to set it up.")
|
64 |
|
65 |
+
if file_prompt is not None:
|
66 |
+
# Initialize an empty list to store file contents
|
67 |
+
file_contents = []
|
68 |
+
for file in file_prompt:
|
69 |
+
# Open the file in read binary mode ('rb')
|
70 |
+
with open(file.name, 'rb') as f:
|
71 |
+
# Read the entire file content into a byte string
|
72 |
+
content = f.read()
|
73 |
+
# Decode the byte string to a UTF-8 string (assuming text file)
|
74 |
+
file_contents.append(content.decode('utf-8'))
|
75 |
+
|
76 |
text_prompt = chatbot[-1][0]
|
77 |
genai.configure(api_key=google_key)
|
78 |
generation_config = genai.types.GenerationConfig(
|