Update databaseengine.py
Browse files- databaseengine.py +8 -3
databaseengine.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
from astrapy import DataAPIClient
|
|
|
|
|
2 |
|
3 |
# Initialize the client
|
4 |
client1 = DataAPIClient("AstraCS:vUPtWJNjuqSJzFwpjwGaIMCG:a763d288a24184d3d8f87e78d8f3a9bdb4e687002ea80fb3e21949b969715b7f")
|
@@ -40,13 +42,16 @@ class DatabaseEngine():
|
|
40 |
|
41 |
contextdocument=collection2.find_one({"version":promptversion})
|
42 |
responsedocument=collection2.find_one({"version":promptversion})
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
return {
|
46 |
"prompt":promptdocument,
|
47 |
"context":contextdocument,
|
48 |
-
"response":
|
49 |
}
|
50 |
-
|
51 |
|
52 |
|
|
|
1 |
from astrapy import DataAPIClient
|
2 |
+
import base64
|
3 |
+
import zlib
|
4 |
|
5 |
# Initialize the client
|
6 |
client1 = DataAPIClient("AstraCS:vUPtWJNjuqSJzFwpjwGaIMCG:a763d288a24184d3d8f87e78d8f3a9bdb4e687002ea80fb3e21949b969715b7f")
|
|
|
42 |
|
43 |
contextdocument=collection2.find_one({"version":promptversion})
|
44 |
responsedocument=collection2.find_one({"version":promptversion})
|
45 |
+
actual_saved_response=responsedocument["response"]
|
46 |
+
|
47 |
+
compressed_data = base64.b64decode(actual_saved_response)
|
48 |
+
decompressed_data = zlib.decompress(compressed_data)
|
49 |
+
actual_original_data=decompressed_data.decode("utf-8")
|
50 |
|
51 |
return {
|
52 |
"prompt":promptdocument,
|
53 |
"context":contextdocument,
|
54 |
+
"response":actual_original_data
|
55 |
}
|
|
|
56 |
|
57 |
|