diff --git a/common/langchain/eveai_retriever.py b/common/langchain/eveai_retriever.py index 7c4b684..1e517f6 100644 --- a/common/langchain/eveai_retriever.py +++ b/common/langchain/eveai_retriever.py @@ -38,7 +38,7 @@ class EveAIRetriever(BaseRetriever, BaseModel): similarity_threshold = self.model_variables['similarity_threshold'] k = self.model_variables['k'] - if self.tenant_info['rag_tuning']: + if self.model_variables['rag_tuning']: try: current_date = get_date_in_timezone(self.tenant_info['timezone']) current_app.rag_tuning_logger.debug(f'Current date: {current_date}\n') @@ -73,7 +73,7 @@ class EveAIRetriever(BaseRetriever, BaseModel): current_app.logger.error(f'Error generating overview: {e}') db.session.rollback() - if self.tenant_info['rag_tuning']: + if self.model_variables['rag_tuning']: current_app.rag_tuning_logger.debug(f'Parameters for Retrieval of documents: \n') current_app.rag_tuning_logger.debug(f'Similarity Threshold: {similarity_threshold}\n') current_app.rag_tuning_logger.debug(f'K: {k}\n') @@ -106,14 +106,14 @@ class EveAIRetriever(BaseRetriever, BaseModel): .limit(k) ) - if self.tenant_info['rag_tuning']: + if self.model_variables['rag_tuning']: current_app.rag_tuning_logger.debug(f'Query executed for Retrieval of documents: \n') current_app.rag_tuning_logger.debug(f'{query_obj.statement}\n') current_app.rag_tuning_logger.debug(f'---------------------------------------\n') res = query_obj.all() - if self.tenant_info['rag_tuning']: + if self.model_variables['rag_tuning']: current_app.rag_tuning_logger.debug(f'Retrieved {len(res)} relevant documents \n') current_app.rag_tuning_logger.debug(f'Data retrieved: \n') current_app.rag_tuning_logger.debug(f'{res}\n') @@ -121,7 +121,7 @@ class EveAIRetriever(BaseRetriever, BaseModel): result = [] for doc in res: - if self.tenant_info['rag_tuning']: + if self.model_variables['rag_tuning']: current_app.rag_tuning_logger.debug(f'Document ID: {doc[0].id} - Distance: {doc[1]}\n') current_app.rag_tuning_logger.debug(f'Chunk: \n {doc[0].chunk}\n\n') result.append(f'SOURCE: {doc[0].id}\n\n{doc[0].chunk}\n\n') diff --git a/common/utils/document_utils.py b/common/utils/document_utils.py index 2014a23..36c96b7 100644 --- a/common/utils/document_utils.py +++ b/common/utils/document_utils.py @@ -345,6 +345,6 @@ def refresh_document(doc_id, tenant_id): # Function triggered when a document_version is created or updated def mark_tenant_storage_dirty(tenant_id): - tenant = db.session.query(Tenant).filter_by(id=tenant_id).first() + tenant = db.session.query(Tenant).filter_by(id=int(tenant_id)).first() tenant.storage_dirty = True db.session.commit() diff --git a/eveai_api/__init__.py b/eveai_api/__init__.py index 9f48b93..3b4a0b0 100644 --- a/eveai_api/__init__.py +++ b/eveai_api/__init__.py @@ -56,13 +56,6 @@ def create_app(config_file=None): app.logger.debug(f'Request URL: {request.url}') app.logger.debug(f'Request headers: {dict(request.headers)}') - # Log request arguments - app.logger.debug(f'Request args: {request.args}') - - # Log form data if it's a POST request - if request.method == 'POST': - app.logger.debug(f'Form data: {request.form}') - # Log JSON data if the content type is application/json if request.is_json: app.logger.debug(f'JSON data: {request.json}') @@ -95,6 +88,10 @@ def create_app(config_file=None): # Don't raise the exception here, let the request continue # The appropriate error handling will be done in the specific endpoints + @app.route('/api/v1') + def swagger(): + return api_rest.render_doc() + return app diff --git a/eveai_api/api/document_api.py b/eveai_api/api/document_api.py index 47728c9..90b6ba5 100644 --- a/eveai_api/api/document_api.py +++ b/eveai_api/api/document_api.py @@ -141,7 +141,7 @@ class AddURL(Resource): file_content, filename, extension = process_url(args['url'], tenant_id) api_input = { - 'catalog_id': args['catlog_id'], + 'catalog_id': args['catalog_id'], 'url': args['url'], 'name': args.get('name') or filename, 'language': args['language'], diff --git a/eveai_app/templates/user/tenant.html b/eveai_app/templates/user/tenant.html index 6c0bc51..7e624b3 100644 --- a/eveai_app/templates/user/tenant.html +++ b/eveai_app/templates/user/tenant.html @@ -47,8 +47,10 @@ {{ render_included_field(field, disabled_fields=[], include_fields=license_fields) }} {% endfor %} - - +
+ + +
api_key = get_option('eveai_api_key'); $this->access_token = get_option('eveai_access_token'); $this->token_expiry = get_option('eveai_token_expiry', 0); + $this->catalog_id = get_option('eveai_catalog_id'); } private function ensure_valid_token() { @@ -111,6 +112,7 @@ class EveAI_API { } public function add_url($data) { + $data['catalog_id'] = get_option('eveai_catalog_id'); // Include catalog_id return $this->make_request('POST', '/api/v1/documents/add_url', $data); }