rameshmoorthy
commited on
Commit
•
5c090df
1
Parent(s):
af4d386
Update app.py
Browse files
app.py
CHANGED
@@ -49,53 +49,53 @@ examples = ['when i have to report to constituency?','what is social media and w
|
|
49 |
|
50 |
|
51 |
|
52 |
-
def get_and_increment_value_count(db , collection_name, field_name):
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
-
def update_count_html():
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
""")
|
86 |
-
|
87 |
|
88 |
-
def store_message(db,query,answer,cross_encoder):
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
|
100 |
|
101 |
def add_text(history, text):
|
|
|
49 |
|
50 |
|
51 |
|
52 |
+
# def get_and_increment_value_count(db , collection_name, field_name):
|
53 |
+
# """
|
54 |
+
# Retrieves a value count from the specified Firestore collection and field,
|
55 |
+
# increments it by 1, and updates the field with the new value."""
|
56 |
+
# collection_ref = db.collection(collection_name)
|
57 |
+
# doc_ref = collection_ref.document('count_doc') # Assuming a dedicated document for count
|
58 |
+
|
59 |
+
# # Use a transaction to ensure consistency across reads and writes
|
60 |
+
# try:
|
61 |
+
# with db.transaction() as transaction:
|
62 |
+
# # Get the current value count (or initialize to 0 if it doesn't exist)
|
63 |
+
# current_count_doc = doc_ref.get()
|
64 |
+
# current_count_data = current_count_doc.to_dict()
|
65 |
+
# if current_count_data:
|
66 |
+
# current_count = current_count_data.get(field_name, 0)
|
67 |
+
# else:
|
68 |
+
# current_count = 0
|
69 |
+
# # Increment the count
|
70 |
+
# new_count = current_count + 1
|
71 |
+
# # Update the document with the new count
|
72 |
+
# transaction.set(doc_ref, {field_name: new_count})
|
73 |
+
# return new_count
|
74 |
+
# except Exception as e:
|
75 |
+
# print(f"Error retrieving and updating value count: {e}")
|
76 |
+
# return None # Indicate error
|
77 |
|
78 |
+
# def update_count_html():
|
79 |
+
# usage_count = get_and_increment_value_count(db ,collection_name, field_name)
|
80 |
+
# ccount_html = gr.HTML(value=f"""
|
81 |
+
# <div style="display: flex; justify-content: flex-end;">
|
82 |
+
# <span style="font-weight: bold; color: maroon; font-size: 18px;">No of Usages:</span>
|
83 |
+
# <span style="font-weight: bold; color: maroon; font-size: 18px;">{usage_count}</span>
|
84 |
+
# </div>
|
85 |
+
# """)
|
86 |
+
# return count_html
|
87 |
|
88 |
+
# def store_message(db,query,answer,cross_encoder):
|
89 |
+
# timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
90 |
+
# # Create a new document reference with a dynamic document name based on timestamp
|
91 |
+
# new_completion= db.collection('Nirvachana').document(f"chatlogs_{timestamp}")
|
92 |
+
# new_completion.set({
|
93 |
+
# 'query': query,
|
94 |
+
# 'answer':answer,
|
95 |
+
# 'created_time': firestore.SERVER_TIMESTAMP,
|
96 |
+
# 'embedding': cross_encoder,
|
97 |
+
# 'title': 'Expenditure observer bot'
|
98 |
+
# })
|
99 |
|
100 |
|
101 |
def add_text(history, text):
|