Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -142,21 +142,23 @@ prompt = ChatPromptTemplate.from_messages([
|
|
142 |
])
|
143 |
|
144 |
def get_collection_files(collection_id: str, user_id: str) -> str:
|
145 |
-
"""Get list of files in the specified collection"""
|
146 |
try:
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
unique_files = df['file_name'].unique()
|
157 |
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
160 |
except Exception as e:
|
161 |
logging.error(f"Error getting collection files: {str(e)}")
|
162 |
return f"Error getting files: {str(e)}"
|
|
|
142 |
])
|
143 |
|
144 |
def get_collection_files(collection_id: str, user_id: str) -> str:
|
145 |
+
"""Get list of files in the specified collection using the external API"""
|
146 |
try:
|
147 |
+
url = f"https://pvanand-documind-api-v2.hf.space/rag/get_collection_files"
|
148 |
+
params = {
|
149 |
+
"collection_id": collection_id,
|
150 |
+
"user_id": user_id
|
151 |
+
}
|
152 |
+
headers = {
|
153 |
+
'accept': 'application/json'
|
154 |
+
}
|
155 |
+
response = requests.post(url, params=params, headers=headers, data='')
|
|
|
156 |
|
157 |
+
if response.status_code == 200:
|
158 |
+
return response.text
|
159 |
+
else:
|
160 |
+
logging.error(f"Error from API: {response.text}")
|
161 |
+
return f"Error getting files: {response.text}"
|
162 |
except Exception as e:
|
163 |
logging.error(f"Error getting collection files: {str(e)}")
|
164 |
return f"Error getting files: {str(e)}"
|