-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlite Changes #472
Sqlite Changes #472
Conversation
* Adding confidence score to entities and topic responses * Adding labels and fixing UTS * Adding utils * Fixing UT * Remove unused imports * Updating topic classifier --------- Co-authored-by: dristy.cd <[email protected]>
* SQLite basic code structure * Changes after testing * Ruff fixes
* Adding confidence score to entities and topic responses * Adding labels and fixing UTS * Adding utils * Fixing UT * Remove unused imports * Updating topic classifier --------- Co-authored-by: dristy.cd <[email protected]>
* Added DB implementation for /prompt API * Updating prompt service --------- Co-authored-by: dristy.cd <[email protected]>
* Discovery api fixes, Update and datetime converted to isoformat * Storage type code optimization * Optimized the way handler method was called based on storage type. * Changes for prompt api * Changes after testing
* Adding confidence score to entities and topic responses (#460) * Adding confidence score to entities and topic responses * Adding labels and fixing UTS * Adding utils * Fixing UT * Remove unused imports * Updating topic classifier --------- Co-authored-by: dristy.cd <[email protected]> * Added changes for prompt group * resolved linting issue * added changes for confidence score for entity classification * added changes for confidence score * review comment changes * review comment changes * review comment changes --------- Co-authored-by: Dristy Srivastava <[email protected]> Co-authored-by: dristy.cd <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial comments
@@ -30,6 +30,7 @@ class CacheDir(Enum): | |||
f"http://{config_details.get('daemon', {}).get('host')}:" | |||
f"{config_details.get('daemon', {}).get('port')}" | |||
) | |||
SQLITE_ENGINE = "sqlite:///{}/pebblo.db" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the path/location to this .db file configurable with a proper default location
* Adding confidence score to entities and topic responses (#460) * Adding confidence score to entities and topic responses * Adding labels and fixing UTS * Adding utils * Fixing UT * Remove unused imports * Updating topic classifier --------- Co-authored-by: dristy.cd <[email protected]> * Added changes for prompt group * resolved linting issue * conflic check fixes * added changes for adding ip address in entity classifier * added test case for ip address --------- Co-authored-by: Dristy Srivastava <[email protected]> Co-authored-by: dristy.cd <[email protected]>
* Storage config code optimized * Loader doc changes
* Chnages for confidence score in /loader/doc as well as UI API * Fixing UTs --------- Co-authored-by: dristy.cd <[email protected]>
* Changes regarding Local UI APIs * Adding AiUser Table * Adding Dashboard API for retrivals * Incorporated code review comments * Adding new filr for local ui APIs for DB * Updated retrievre app API * Added username in AiRetrievals --------- Co-authored-by: dristy.cd <[email protected]>
* Loader doc changes * Renamed sqlite db file name. * Changed docIds to snippetIds * Add feature to show execution time for functions with database operations * LoadId's added in all sql tables
#482) * Adding confidence score to entities and topic responses (#460) * Adding confidence score to entities and topic responses * Adding labels and fixing UTS * Adding utils * Fixing UT * Remove unused imports * Updating topic classifier --------- Co-authored-by: dristy.cd <[email protected]> * Added changes for prompt group * resolved linting issue * conflic check fixes * added changes for adding ip address in entity classifier * added test case for ip address * added fix for entity classification happening in prompt api for prompt --------- Co-authored-by: Dristy Srivastava <[email protected]> Co-authored-by: dristy.cd <[email protected]>
* Fixed issues found while testing. * Ruff fixes.
* Adding retriever API for local UI for DB Apps * Adding delete API for Retriever DB apps
2506711
to
400f638
Compare
* Added local-ui utils file
* Local UI - LoaderApp details page UI. * Fixed commit issue by adding flag_modified() method. * Fixed regression on local UI with file storage.
pebblo/app/models/sqltables.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these table_name comes from a ENUM?
AiUser, ai_user_obj.dict() | ||
) | ||
if insert_status: | ||
logger.debug(f"Entry: {entry} in AiUser completed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log "entry"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dristysrivastava Can you please check this?
return datetime.now().isoformat() | ||
|
||
|
||
def timeit(func): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can timeit function have a condition in the beginning because everytime we will calculate the time for each function but not log it.. So can it only run when the deubg mode is on else it just returns from the first line itself
return doc_info | ||
except Exception as e: | ||
logger.error( | ||
f"Get Classifier Response Failed for doc: {doc}, Exception: {e}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log doc. Can we do it with some id etc... ?
else: | ||
# If entity or topic does not exist in app coll | ||
restricted_data[data] = { | ||
"count": doc_restricted_data.get(data, 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can directly assign 0 in "count" no need for get operation
Aggregating all input, processing the data, and generating the final report | ||
""" | ||
logger.debug("Generating final report") | ||
logger.debug(f"LoaderApp: {app_data}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log raw data and app data
:return: sorted retrievals list | ||
""" | ||
sorted_data = sorted( | ||
retrievals, key=lambda item: len(item["retrievals"]), reverse=True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use get len(item["retrievals"]),?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we are using len()
and the apply sorted()
on top of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
* Updating /prompt/ as well as /delete API * Removed multiple commit statements * Moved response models in db response file * Updating models * Updating model fields --------- Co-authored-by: dristy.cd <[email protected]>
def _get_app_type_and_class(self): | ||
AppClass = None | ||
app_type = None | ||
load_id = self.data.get("load_id") or None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add None in get function itself
@timeit | ||
def process_request(self, data): | ||
try: | ||
self.db = SQLiteClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are creating SqliteClient in every request. Is it possible to create a db client once and use it across when the pebblo server starts? Maybe a Singleton class or any other option?
* Generate PDF at the end of loder/doc API. * Delete loader app
|
||
exist, existing_ai_app = db.query(app_class, ai_app) | ||
if exist and existing_ai_app: | ||
logger.debug(f"Application details exists in {app_class.__tablename__}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a specific prefix in the logger message like - LoaderApp: as we had done in last release
else: | ||
raise Exception(result) | ||
except Exception as err: | ||
message = f"PDF report is not generated. Error: {err}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this message is going to the UI should we remove ex ?
Should this be done across all apis ..
else: | ||
# Commit will only happen when everything went well. | ||
message = "App Discover Request Processed Successfully" | ||
logger.debug(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add an idetifier in the log messsage
This should be done in all the log messages
Co-authored-by: dristy.cd <[email protected]>
* Made sqlite table creation conditional. * Test cases fixed * Ruff fixes.
Items covered:
Pending items: