Spaces:
Running
Running
Louis-François Bouchard
Omar Solano
Omar Solano
commited on
Add time data (#49)
Browse files* Openai activeloop data (#37)
* adding openai and activeloop data
* fixing issues with names
* concurrency
* black
* black
* revert to gradio3.50 for concurrency
---------
Co-authored-by: Omar Solano <[email protected]>
* ensure gradio version for HF
* Updates to files
* Push to advanced rag course
* edits to prompt
* Add datetime to mongodb logs
---------
Co-authored-by: Omar Solano <[email protected]>
Co-authored-by: Omar Solano <[email protected]>
app.py
CHANGED
@@ -2,6 +2,7 @@ import logging
|
|
2 |
import os
|
3 |
from typing import Optional
|
4 |
import time
|
|
|
5 |
|
6 |
import gradio as gr
|
7 |
import pandas as pd
|
@@ -57,14 +58,19 @@ logging.basicConfig(level=logging.INFO)
|
|
57 |
def save_completion(completion: Completion, question: gr.Textbox):
|
58 |
collection = "completion_data-hf"
|
59 |
|
|
|
60 |
completion_json = completion.to_json(
|
61 |
columns_to_ignore=["embedding", "similarity", "similarity_to_answer"]
|
62 |
)
|
|
|
|
|
|
|
|
|
63 |
try:
|
64 |
cfg.mongo_db[collection].insert_one(completion_json)
|
65 |
logger.info("Completion saved to db")
|
66 |
-
except:
|
67 |
-
logger.info("Something went wrong logging completion to db")
|
68 |
|
69 |
|
70 |
def log_likes(completion: Completion, like_data: gr.LikeData):
|
|
|
2 |
import os
|
3 |
from typing import Optional
|
4 |
import time
|
5 |
+
from datetime import datetime
|
6 |
|
7 |
import gradio as gr
|
8 |
import pandas as pd
|
|
|
58 |
def save_completion(completion: Completion, question: gr.Textbox):
|
59 |
collection = "completion_data-hf"
|
60 |
|
61 |
+
# Convert completion to JSON and ignore certain columns
|
62 |
completion_json = completion.to_json(
|
63 |
columns_to_ignore=["embedding", "similarity", "similarity_to_answer"]
|
64 |
)
|
65 |
+
|
66 |
+
# Add the current date and time to the JSON
|
67 |
+
completion_json["timestamp"] = datetime.utcnow().isoformat()
|
68 |
+
|
69 |
try:
|
70 |
cfg.mongo_db[collection].insert_one(completion_json)
|
71 |
logger.info("Completion saved to db")
|
72 |
+
except Exception as e:
|
73 |
+
logger.info(f"Something went wrong logging completion to db: {e}")
|
74 |
|
75 |
|
76 |
def log_likes(completion: Completion, like_data: gr.LikeData):
|