Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions changai/changai/api/v1/prediction_pipeline_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
import jinja2
from typing import Any, Dict, Optional
from symspellpy.symspellpy import SymSpell, Verbosity
from changai.changai.api.v2.text2sql_pipeline import get_settings
# from changai.changai.api.v2.text2sql_pipeline import get_settings

CONFIG=get_settings()
pleasantry_file_path = frappe.get_app_path("changai", "changai", "api", "pleasantry.json")
business_keywords_file = frappe.get_app_path("changai", "changai", "api", "business_keywords.json")
custom_dictionary = frappe.get_app_path("changai", "changai", "api", "erp_dictionary.txt")
Expand Down
2 changes: 1 addition & 1 deletion changai/changai/api/v2/ai_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ def translate_and_store(docname: str, doctype: str, from_field: str, to_field: s
if not hasattr(doc, to_field):
frappe.throw(f"Field '{to_field}' does not exist on Item")
doc.set(to_field, translated_text)
doc.save(ignore_permissions=True)
doc.save(ignore_permissions=False)
return to_field
2 changes: 1 addition & 1 deletion changai/changai/api/v2/assets/business_keywords_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
"show fields",
"child",
"show all fields",
"show customer names",
"employee name",
"name",
"invoice number",
"quotation number",
"purchase order number",
Expand Down
Binary file modified changai/changai/api/v2/fvs_stores/erpnext/emb_dir/field_docs.pkl
Binary file not shown.
Binary file modified changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.faiss
Binary file not shown.
Binary file modified changai/changai/api/v2/fvs_stores/erpnext/report_fvs/index.pkl
Binary file not shown.
Binary file modified changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.faiss
Binary file not shown.
Binary file modified changai/changai/api/v2/fvs_stores/erpnext/table_fvs/index.pkl
Binary file not shown.
26 changes: 8 additions & 18 deletions changai/changai/api/v2/schema_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def is_master_data_changed(last_sync: str, stored_data: list):
return True
return False


@frappe.whitelist(allow_guest=True)
def check_file_updates(file_name: str):
RAG_FOLDER = "Home/RAG Sources"
from changai.changai.api.v2.build_cards_faiss_index_v2 import _read_file_doc
Expand Down Expand Up @@ -542,7 +542,7 @@ class ChangAIConfig:
def get(cls):
if not hasattr(frappe.local, "_changai_config"):
frappe.clear_document_cache(CHANGAI_SETTINGS)
frappe.local._changai_config = get_settings()
frappe.local._changai_config = _get_internal_settings_config()
return frappe.local._changai_config


Expand All @@ -555,21 +555,7 @@ def _build_frontend_settings_config() -> Dict[str, Any]:
or getattr(settings, "aws_default_region", None)
or "us-east-1"
)

return {
"RETAIN_MEM": settings.retain_memory,
"LLM_VERSION_ID": settings.llm_version_id,
"EMBED_VERSION_ID": settings.embedder_version_id,
"REMOTE": bool(settings.remote),
"deploy_url": settings.deploy_url,
"entity_retriever": settings.entity_retriever,
"support_api_url": settings.support_url,
"get_ticket_details_url": settings.get_ticket_details_url,
"llm": settings.llm,
"location": settings.gemini_location,
"retriever_structure": settings.retriever_structure,
"gemini_project_id": settings.gemini_project_id,
"gemini_json_content": settings.gemini_json_content,
"enable_voice_chat": bool(settings.enable_voice_chat),
"aws_region": aws_region,
"polly_voice_id": "Zayd",
Expand All @@ -578,8 +564,7 @@ def _build_frontend_settings_config() -> Dict[str, Any]:
}


@frappe.whitelist(allow_guest=False)
def get_settings() -> Dict[str, Any]:
def _get_internal_settings_config() -> Dict[str, Any]:
settings = frappe.get_single(CHANGAI_SETTINGS)
config = {
"RETAIN_MEM": settings.retain_memory,
Expand All @@ -602,9 +587,14 @@ def get_settings() -> Dict[str, Any]:
}
return config

@frappe.whitelist(allow_guest=False)
def get_settings() -> Dict[str, Any]:
frappe.has_permission(CHANGAI_SETTINGS, "read", throw=True)
return _get_internal_settings_config()

@frappe.whitelist(allow_guest=False)
def get_frontend_settings() -> Dict[str, Any]:
frappe.has_permission(CHANGAI_SETTINGS, "read", throw=True)
return _build_frontend_settings_config()

def clean_sql(s: Any) -> str:
Expand Down
2 changes: 1 addition & 1 deletion changai/changai/api/v2/store_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def find_similar_log_question(new_question: str, threshold: int = 98):

score = fuzz.token_set_ratio(
new_question,
log.user_question
log.rewritten_question
)

if score > best_score:
Expand Down
Loading
Loading