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 %}
-
-
+
diff --git a/eveai_app/views/document_views.py b/eveai_app/views/document_views.py
index a45a48e..f8f2a4b 100644
--- a/eveai_app/views/document_views.py
+++ b/eveai_app/views/document_views.py
@@ -135,6 +135,14 @@ def edit_catalog(catalog_id):
form = CatalogForm(obj=catalog)
tenant_id = session.get('tenant').get('id')
+ # Convert arrays to comma-separated strings for display
+ if request.method == 'GET':
+ form.html_tags.data = ', '.join(catalog.html_tags or '')
+ form.html_end_tags.data = ', '.join(catalog.html_end_tags or '')
+ form.html_included_elements.data = ', '.join(catalog.html_included_elements or '')
+ form.html_excluded_elements.data = ', '.join(catalog.html_excluded_elements or '')
+ form.html_excluded_classes.data = ', '.join(catalog.html_excluded_classes or '')
+
if request.method == 'POST' and form.validate_on_submit():
form.populate_obj(catalog)
# Handle Embedding Variables
diff --git a/eveai_chat_workers/tasks.py b/eveai_chat_workers/tasks.py
index 4733658..90f6641 100644
--- a/eveai_chat_workers/tasks.py
+++ b/eveai_chat_workers/tasks.py
@@ -93,12 +93,6 @@ def ask_question(tenant_id, question, language, session_id, user_timezone, room)
current_app.logger.error(f'ask_question: Error initializing chat session in database: {e}')
raise
- if tenant.rag_tuning:
- current_app.rag_tuning_logger.debug(f'Received question for tenant {tenant_id}:\n{question}. Processing...')
- current_app.rag_tuning_logger.debug(f'Tenant Information: \n{tenant.to_dict()}')
- current_app.rag_tuning_logger.debug(f'===================================================================')
- current_app.rag_tuning_logger.debug(f'===================================================================')
-
with current_event.create_span("RAG Answer"):
result, interaction = answer_using_tenant_rag(question, language, tenant, chat_session)
result['algorithm'] = current_app.config['INTERACTION_ALGORITHMS']['RAG_TENANT']['name']
@@ -138,8 +132,7 @@ def answer_using_tenant_rag(question, language, tenant, chat_session):
with current_event.create_span("Detail Question"):
detailed_question = detail_question(question, language, model_variables, chat_session.session_id)
- current_app.logger.debug(f'Original question:\n {question}\n\nDetailed question: {detailed_question}')
- if tenant.rag_tuning:
+ if model_variables['rag_tuning']:
current_app.rag_tuning_logger.debug(f'Detailed Question for tenant {tenant.id}:\n{question}.')
current_app.rag_tuning_logger.debug(f'-------------------------------------------------------------------')
new_interaction.detailed_question = detailed_question
@@ -153,7 +146,7 @@ def answer_using_tenant_rag(question, language, tenant, chat_session):
full_template = replace_variable_in_template(language_template, "{tenant_context}", model_variables['rag_context'])
rag_prompt = ChatPromptTemplate.from_template(full_template)
setup_and_retrieval = RunnableParallel({"context": retriever, "question": RunnablePassthrough()})
- if tenant.rag_tuning:
+ if model_variables['rag_tuning']:
current_app.rag_tuning_logger.debug(f'Full prompt for tenant {tenant.id}:\n{full_template}.')
current_app.rag_tuning_logger.debug(f'-------------------------------------------------------------------')
@@ -181,7 +174,7 @@ def answer_using_tenant_rag(question, language, tenant, chat_session):
current_app.logger.debug(f'ask_question: result answer: {result['answer']}')
current_app.logger.debug(f'ask_question: result citations: {result["citations"]}')
current_app.logger.debug(f'ask_question: insufficient information: {result["insufficient_info"]}')
- if tenant.rag_tuning:
+ if model_variables['rag_tuning']:
current_app.rag_tuning_logger.debug(f'ask_question: result answer: {result['answer']}')
current_app.rag_tuning_logger.debug(f'ask_question: result citations: {result["citations"]}')
current_app.rag_tuning_logger.debug(f'ask_question: insufficient information: {result["insufficient_info"]}')
@@ -197,7 +190,7 @@ def answer_using_tenant_rag(question, language, tenant, chat_session):
)
existing_embedding_ids = [emb.id for emb in embeddings]
urls = list(set(emb.document_version.url for emb in embeddings))
- if tenant.rag_tuning:
+ if model_variables['rag_tuning']:
current_app.rag_tuning_logger.debug(f'Referenced documents for answer for tenant {tenant.id}:\n')
current_app.rag_tuning_logger.debug(f'{urls}')
current_app.rag_tuning_logger.debug(f'-------------------------------------------------------------------')
diff --git a/eveai_workers/Processors/html_processor.py b/eveai_workers/Processors/html_processor.py
index bd5f119..9f0ddb4 100644
--- a/eveai_workers/Processors/html_processor.py
+++ b/eveai_workers/Processors/html_processor.py
@@ -15,6 +15,7 @@ class HTMLProcessor(Processor):
self.html_end_tags = model_variables['html_end_tags']
self.html_included_elements = model_variables['html_included_elements']
self.html_excluded_elements = model_variables['html_excluded_elements']
+ self.html_excluded_classes = model_variables['html_excluded_classes']
self.chunk_size = model_variables['processing_chunk_size'] # Adjust this based on your LLM's optimal input size
self.chunk_overlap = model_variables[
'processing_chunk_overlap'] # Adjust for context preservation between chunks
@@ -45,7 +46,7 @@ class HTMLProcessor(Processor):
self._log(f'Parsing HTML for tenant {self.tenant.id}')
soup = BeautifulSoup(html_content, 'html.parser')
extracted_html = ''
- excluded_classes = self._parse_excluded_classes(self.tenant.html_excluded_classes)
+ excluded_classes = self._parse_excluded_classes(self.html_excluded_classes)
if self.html_included_elements:
elements_to_parse = soup.find_all(self.html_included_elements)
diff --git a/integrations/Wordpress/eveai_sync/README.md b/integrations/Wordpress/eveai_sync/README.md
index 20a448d..574cfe2 100644
--- a/integrations/Wordpress/eveai_sync/README.md
+++ b/integrations/Wordpress/eveai_sync/README.md
@@ -51,6 +51,10 @@ No additional configuration is needed; the plugin will automatically detect the
## Versions
+### 1.1.1 - Add Reinitialisation functionality
+
+### 1.1.0 - Add Catalog Functionality
+
### 1.0.x - Bugfixing Releases
### 1.0.0 - Initial Release
diff --git a/integrations/Wordpress/eveai_sync/eveai_sync.php b/integrations/Wordpress/eveai_sync/eveai_sync.php
index 2b5f2ca..7eed7a7 100644
--- a/integrations/Wordpress/eveai_sync/eveai_sync.php
+++ b/integrations/Wordpress/eveai_sync/eveai_sync.php
@@ -3,7 +3,7 @@
* Plugin Name: EveAI Sync
* Plugin URI: https://askeveai.com/
* Description: Synchronizes WordPress content with EveAI API.
- * Version: 1.0.16
+ * Version: 1.1.1
* Author: Josako, Pieter Laroy
* Author URI: https://askeveai.com/about/
* License: GPL v2 or later
@@ -17,7 +17,7 @@ if (!defined('ABSPATH')) {
}
// Define plugin constants
-define('EVEAI_SYNC_VERSION', '1.0.0');
+define('EVEAI_SYNC_VERSION', '1.1.1');
define('EVEAI_SYNC_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('EVEAI_SYNC_PLUGIN_URL', plugin_dir_url(__FILE__));
@@ -50,6 +50,30 @@ function eveai_delete_post_meta($post_id) {
}
add_action('before_delete_post', 'eveai_delete_post_meta');
+// Clean metadata from Wordpress site
+function eveai_reinitialize_site() {
+ check_ajax_referer('eveai_reinitialize_site', 'nonce');
+
+ if (!current_user_can('manage_options')) {
+ wp_send_json_error('You do not have permission to perform this action.');
+ return;
+ }
+
+ global $wpdb;
+
+ // Remove all EveAI-related post meta
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '_eveai_%'");
+
+ // Remove all EveAI-related options
+ delete_option('eveai_last_sync_time');
+ delete_option('eveai_sync_status');
+
+ // Optionally, you might want to clear any custom tables if you have any
+
+ wp_send_json_success('Site reinitialized. All EveAI metadata has been removed.');
+}
+add_action('wp_ajax_eveai_reinitialize_site', 'eveai_reinitialize_site');
+
// Display sync info in post
function eveai_display_sync_info($post) {
$document_id = get_post_meta($post->ID, '_eveai_document_id', true);
diff --git a/integrations/Wordpress/eveai_sync/includes/class-eveai-admin.php b/integrations/Wordpress/eveai_sync/includes/class-eveai-admin.php
index b6ad673..17ab0bb 100644
--- a/integrations/Wordpress/eveai_sync/includes/class-eveai-admin.php
+++ b/integrations/Wordpress/eveai_sync/includes/class-eveai-admin.php
@@ -16,6 +16,7 @@ class EveAI_Admin {
register_setting('eveai_settings', 'eveai_excluded_categories');
register_setting('eveai_settings', 'eveai_access_token');
register_setting('eveai_settings', 'eveai_token_expiry');
+ register_setting('eveai_settings', 'eveai_catalog_id');
}
public function add_admin_menu() {
@@ -50,6 +51,10 @@ class EveAI_Admin {
API Key |
|
+
+ | Catalog ID |
+ |
+
| Default Language |
|
@@ -71,6 +76,11 @@ class EveAI_Admin {
+
+ Reinitialize Site
+ Click the button below to remove all EveAI metadata from your site. This will reset the sync status for all posts and pages.
+
+
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);
}