Temporary fixing bug loggorilla in TUI

This commit is contained in:
Dita Aji Pratama 2026-10-07 16:50:19 +07:00
parent 37c68a9ade
commit 870dcaea94

View File

@ -1,5 +1,7 @@
import os import os
from scripts import loggorilla # NOTE: loggorilla dimatikan di tool ini. print()-nya bisa bikin error saat
# proses keluar (SCI), jadi semua pemanggilan di bawah hanya di-comment, jangan dihapus.
# from scripts import loggorilla
schema_instruction_use = { schema_instruction_use = {
"type": "function", "type": "function",
@ -24,7 +26,7 @@ schema_instruction_use = {
} }
def instruction_use(directory, filename): def instruction_use(directory, filename):
loggorilla.fyinf("tools.smart", f"Calling instruction_use with directory='{directory}', filename='{filename}'") # loggorilla.fyinf("tools.smart", f"Calling instruction_use with directory='{directory}', filename='{filename}'")
current_file_dir = os.path.dirname(os.path.abspath(__file__)) current_file_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(current_file_dir) project_root = os.path.dirname(current_file_dir)
base_dir = os.path.join(project_root, "instruction") base_dir = os.path.join(project_root, "instruction")
@ -34,15 +36,15 @@ def instruction_use(directory, filename):
if not os.path.exists(file_path): if not os.path.exists(file_path):
res = f"Error: Instruction file not found at {file_path}" res = f"Error: Instruction file not found at {file_path}"
loggorilla.fyinf("tools.smart", f"File not found: {res}") # loggorilla.fyinf("tools.smart", f"File not found: {res}")
return res return res
try: try:
with open(file_path, 'r', encoding='utf-8') as f: with open(file_path, 'r', encoding='utf-8') as f:
content = f.read() content = f.read()
loggorilla.fyinf("tools.smart", f"Successfully read file. Content snippet: {content[:100]}...") # loggorilla.fyinf("tools.smart", f"Successfully read file. Content snippet: {content[:100]}...")
return content return content
except Exception as e: except Exception as e:
res = f"Error reading file: {str(e)}" res = f"Error reading file: {str(e)}"
loggorilla.fyinf("tools.smart", f"Exception occurred: {res}") # loggorilla.fyinf("tools.smart", f"Exception occurred: {res}")
return res return res