erd cleanup

This commit is contained in:
ValueOn AG 2025-05-17 11:38:38 +02:00
parent 2ddf38d7cd
commit 16338a6f94
33 changed files with 237 additions and 254 deletions

30
app.py
View file

@ -3,7 +3,6 @@ os.environ["NUMEXPR_MAX_THREADS"] = "12"
from fastapi import FastAPI, HTTPException, Depends, Body, status, Response from fastapi import FastAPI, HTTPException, Depends, Body, status, Response
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from contextlib import asynccontextmanager from contextlib import asynccontextmanager
import logging import logging
@ -11,7 +10,7 @@ from logging.handlers import RotatingFileHandler
from datetime import timedelta from datetime import timedelta
import pathlib import pathlib
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
def initLogging(): def initLogging():
# Get log level from config (default to INFO if not found) # Get log level from config (default to INFO if not found)
@ -59,8 +58,7 @@ logger = logging.getLogger(__name__)
instanceLabel = APP_CONFIG.get("APP_ENV_LABEL") instanceLabel = APP_CONFIG.get("APP_ENV_LABEL")
# Import models - import generically for INITIALIZATION # Import models - import generically for INITIALIZATION
import modules.gatewayModel as gatewayModel from modules.interfaces.gatewayInterface import getGatewayInterface
from modules.gatewayInterface import getGatewayInterface
gateway = getGatewayInterface() gateway = getGatewayInterface()
@ -99,35 +97,27 @@ app.add_middleware(
max_age=86400 # Increased caching for preflight requests max_age=86400 # Increased caching for preflight requests
) )
# Static folder for frontend - work with absolute path
baseDir = pathlib.Path(__file__).parent
staticFolder = baseDir / "static"
os.makedirs(staticFolder, exist_ok=True)
# Mount static files with proper configuration
app.mount("/static", StaticFiles(directory=str(staticFolder), html=True), name="static")
# Include all routers # Include all routers
from routes.routeGeneral import router as generalRouter from modules.routes.routeGeneral import router as generalRouter
app.include_router(generalRouter) app.include_router(generalRouter)
from routes.routeAttributes import router as attributesRouter from modules.routes.routeAttributes import router as attributesRouter
app.include_router(attributesRouter) app.include_router(attributesRouter)
from routes.routeMandates import router as mandateRouter from modules.routes.routeMandates import router as mandateRouter
app.include_router(mandateRouter) app.include_router(mandateRouter)
from routes.routeUsers import router as userRouter from modules.routes.routeUsers import router as userRouter
app.include_router(userRouter) app.include_router(userRouter)
from routes.routeFiles import router as fileRouter from modules.routes.routeFiles import router as fileRouter
app.include_router(fileRouter) app.include_router(fileRouter)
from routes.routePrompts import router as promptRouter from modules.routes.routePrompts import router as promptRouter
app.include_router(promptRouter) app.include_router(promptRouter)
from routes.routeWorkflows import router as workflowRouter from modules.routes.routeWorkflows import router as workflowRouter
app.include_router(workflowRouter) app.include_router(workflowRouter)
from routes.routeMsft import router as msftRouter from modules.routes.routeMsft import router as msftRouter
app.include_router(msftRouter) app.include_router(msftRouter)

View file

@ -12,7 +12,7 @@ import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import seaborn as sns import seaborn as sns
from modules.workflowAgentsRegistry import AgentBase from modules.workflow.agentBase import AgentBase
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -8,7 +8,7 @@ from typing import Dict, Any, List
import json import json
from datetime import datetime from datetime import datetime
from modules.workflowAgentsRegistry import AgentBase from modules.workflow.agentBase import AgentBase
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,19 +1,22 @@
""" """
Simple Coder Agent for execution of Python code. Coder agent for generating and executing code.
Modified to pass expected output document names to the generated code. Provides code generation, execution, and improvement capabilities.
""" """
import logging import logging
from typing import Dict, Any, List, Tuple
import json import json
import os import os
import sys
import subprocess import subprocess
import tempfile import tempfile
import shutil import shutil
import sys import venv
from typing import Dict, Any, List, Tuple import importlib.util
from datetime import datetime
from modules.workflowAgentsRegistry import AgentBase from modules.workflow.agentBase import AgentBase
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,13 +1,15 @@
""" """
Documentation agent for creating documentation, reports, and structured content. Documentation agent for generating structured documentation.
Reimagined with an output-first, AI-driven approach with multi-step document generation. Provides comprehensive documentation generation capabilities.
""" """
import logging import logging
import json
from typing import Dict, Any, List from typing import Dict, Any, List
import json
import re
from datetime import datetime
from modules.workflowAgentsRegistry import AgentBase from modules.workflow.agentBase import AgentBase
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,18 +1,21 @@
""" """
Email agent for creating draft emails with Microsoft Graph API. Email agent for generating and sending emails.
Creates HTML-formatted email templates with attachments based on input documents. Provides email template generation and sending capabilities.
""" """
import logging import logging
from typing import Dict, Any, List, Tuple
import json import json
import base64
import os import os
import requests import requests
import base64
from datetime import datetime
import re
from bs4 import BeautifulSoup
import msal import msal
from typing import Dict, Any, List, Optional from modules.shared.configuration import APP_CONFIG
from modules.configuration import APP_CONFIG
from modules.workflowAgentsRegistry import AgentBase from modules.workflow.agentBase import AgentBase
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,6 +1,6 @@
""" """
Webcrawler agent for research and retrieval of information from the web. Web crawler agent for gathering and analyzing web content.
Reimagined with an output-first, AI-driven approach. Provides web research and content extraction capabilities.
""" """
import logging import logging
@ -14,8 +14,8 @@ from bs4 import BeautifulSoup
import requests import requests
import markdown import markdown
from modules.workflowAgentsRegistry import AgentBase from modules.workflow.agentBase import AgentBase
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -2,7 +2,7 @@ import logging
import httpx import httpx
from typing import Dict, Any, List, Union from typing import Dict, Any, List, Union
from fastapi import HTTPException from fastapi import HTTPException
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
# Configure logger # Configure logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -3,7 +3,7 @@ import base64
import httpx import httpx
from typing import Dict, Any, List, Union from typing import Dict, Any, List, Union
from fastapi import HTTPException from fastapi import HTTPException
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
# Configure logger # Configure logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -9,9 +9,9 @@ from typing import Dict, Any, List, Optional, Union
import importlib import importlib
from passlib.context import CryptContext from passlib.context import CryptContext
from connectors.connectorDbJson import DatabaseConnector from modules.connectors.connectorDbJson import DatabaseConnector
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
from modules.gatewayAccess import _uam, _canModify from modules.interfaces.gatewayAccess import _uam, _canModify
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -31,14 +31,6 @@ class GatewayInterface:
self.mandateId = mandateId self.mandateId = mandateId
self.userId = userId self.userId = userId
# Import data model module
try:
self.modelModule = importlib.import_module("modules.gatewayModel")
logger.info("gatewayModel successfully imported")
except ImportError as e:
logger.error(f"Error importing gatewayModel: {e}")
raise
# Initialize database # Initialize database
self._initializeDatabase() self._initializeDatabase()

View file

@ -13,15 +13,15 @@ import importlib
import hashlib import hashlib
import json import json
from modules.mimeUtils import isTextMimeType, determineContentEncoding from modules.shared.mimeUtils import isTextMimeType, determineContentEncoding
from modules.lucydomAccess import LucyDOMAccess from modules.interfaces.lucydomAccess import LucyDOMAccess
# DYNAMIC PART: Connectors to the Interface # DYNAMIC PART: Connectors to the Interface
from connectors.connectorDbJson import DatabaseConnector from modules.connectors.connectorDbJson import DatabaseConnector
from connectors.connectorAiOpenai import ChatService from modules.connectors.connectorAiOpenai import ChatService
# Basic Configurations # Basic Configurations
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# Custom exceptions for file handling # Custom exceptions for file handling
@ -61,14 +61,6 @@ class LucyDOMInterface:
self.userLanguage = "en" # Default user language self.userLanguage = "en" # Default user language
self.aiService = None # Will be set externally self.aiService = None # Will be set externally
# Import data model module
try:
self.modelModule = importlib.import_module("modules.lucydomModel")
logger.info("lucydomModel successfully imported")
except ImportError as e:
logger.error(f"Error importing lucydomModel: {e}")
raise
# Initialize database connector # Initialize database connector
self._initializeDatabase() self._initializeDatabase()

View file

@ -183,20 +183,6 @@ class Workflow(BaseModel):
# Agent and Workflow Task Models # Agent and Workflow Task Models
class AgentTask(BaseModel):
"""Standardized task structure for agent processing"""
taskId: str = Field(description="Unique ID for this task")
workflowId: str = Field(description="ID of the parent workflow")
prompt: str = Field(description="The main instruction for the agent")
inputDocuments: List[Document] = Field(default=[], description="List of document objects to process")
outputSpecifications: List[Dict[str, str]] = Field(default=[], description="List of required output documents")
context: Dict[str, Any] = Field(description="Additional contextual information")
label: Label = Field(
default=Label(default="Agent Task", translations={"en": "Agent Task", "fr": "Tâche d'agent"}),
description="Label for the class"
)
class AgentResult(BaseModel): class AgentResult(BaseModel):
"""Result structure returned by agent processing""" """Result structure returned by agent processing"""
feedback: str = Field(description="Text response explaining what the agent did") feedback: str = Field(description="Text response explaining what the agent did")
@ -218,6 +204,8 @@ class AgentInfo(BaseModel):
description="Label for the class" description="Label for the class"
) )
class InputDocument(BaseModel): class InputDocument(BaseModel):
"""Input document specification for a task""" """Input document specification for a task"""
label: str = Field(description="Document label in the format 'filename.ext'") label: str = Field(description="Document label in the format 'filename.ext'")
@ -268,15 +256,6 @@ class WorkflowStatus(BaseModel):
description="Label for the class" description="Label for the class"
) )
class WorkflowLabels(BaseModel):
"""Global workflow labels and messages"""
systemName: str = Field(default="AI Assistant")
workflowStatusMessages: WorkflowStatus = Field(default_factory=WorkflowStatus)
label: Label = Field(
default=Label(default="Workflow Labels", translations={"en": "Workflow Labels", "fr": "Étiquettes du workflow"}),
description="Label for the class"
)
# Request models for the API # Request models for the API

View file

@ -2,14 +2,14 @@ from fastapi import APIRouter, HTTPException, Depends, Path, Response
from typing import List, Dict, Any from typing import List, Dict, Any
from fastapi import status from fastapi import status
from modules.auth import getCurrentActiveUser, getUserContext from modules.security.auth import getCurrentActiveUser, getUserContext
# Import the attribute definition and helper functions # Import the attribute definition and helper functions
from modules.defAttributes import AttributeDefinition, getModelAttributes from modules.shared.defAttributes import AttributeDefinition, getModelAttributes
# Import the model modules (without specific classes) # Import the model modules (without specific classes)
import modules.gatewayModel as gatewayModel import modules.interfaces.gatewayModel as gatewayModel
import modules.lucydomModel as lucydomModel import modules.interfaces.lucydomModel as lucydomModel
modelClasses = { modelClasses = {
# Gateway model classes # Gateway model classes

View file

@ -6,12 +6,12 @@ from datetime import datetime
from dataclasses import dataclass from dataclasses import dataclass
import io import io
from modules.auth import getCurrentActiveUser, getUserContext from modules.security.auth import getCurrentActiveUser, getUserContext
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
# Import interfaces # Import interfaces
from modules.lucydomInterface import getLucydomInterface, FileError, FileNotFoundError, FileStorageError, FilePermissionError, FileDeletionError from modules.interfaces.lucydomInterface import getLucydomInterface, FileError, FileNotFoundError, FileStorageError, FilePermissionError, FileDeletionError
from modules.lucydomModel import FileItem from modules.interfaces.lucydomModel import FileItem
# Configure logger # Configure logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,26 +1,31 @@
from fastapi import APIRouter, HTTPException, Depends, Body, status, Response from fastapi import APIRouter, HTTPException, Depends, Body, status, Response
from fastapi.responses import FileResponse from fastapi.responses import FileResponse
from fastapi.security import OAuth2PasswordRequestForm from fastapi.security import OAuth2PasswordRequestForm
from fastapi.staticfiles import StaticFiles
from typing import Dict, Any from typing import Dict, Any
from datetime import timedelta from datetime import timedelta
import pathlib import pathlib
import os import os
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
from modules.auth import ( from modules.security.auth import (
createAccessToken, createAccessToken,
getCurrentActiveUser, getCurrentActiveUser,
getUserContext, getUserContext,
ACCESS_TOKEN_EXPIRE_MINUTES ACCESS_TOKEN_EXPIRE_MINUTES
) )
import modules.gatewayModel as gatewayModel import modules.interfaces.gatewayModel as gatewayModel
from modules.gatewayInterface import getGatewayInterface from modules.interfaces.gatewayInterface import getGatewayInterface
router = APIRouter() router = APIRouter()
# Static folder for favicon # Static folder setup - using absolute path from app root
baseDir = pathlib.Path(__file__).parent.parent baseDir = pathlib.Path(__file__).parent.parent.parent # Go up to gateway root
staticFolder = baseDir / "static" staticFolder = baseDir / "static"
os.makedirs(staticFolder, exist_ok=True)
# Mount static files
router.mount("/static", StaticFiles(directory=str(staticFolder), html=True), name="static")
@router.get("/favicon.ico") @router.get("/favicon.ico")
async def favicon(): async def favicon():

View file

@ -5,9 +5,9 @@ from datetime import datetime
from dataclasses import dataclass from dataclasses import dataclass
# Import interfaces # Import interfaces
from modules.auth import getCurrentActiveUser, getUserContext from modules.security.auth import getCurrentActiveUser, getUserContext
from modules.gatewayInterface import getGatewayInterface from modules.interfaces.gatewayInterface import getGatewayInterface
from modules.gatewayModel import Mandate from modules.interfaces.gatewayModel import Mandate
# Determine all attributes of the model # Determine all attributes of the model
def getModelAttributes(modelClass): def getModelAttributes(modelClass):

View file

@ -7,10 +7,10 @@ from typing import Dict, Any, Optional, List
from datetime import datetime, timedelta from datetime import datetime, timedelta
import secrets import secrets
from modules.auth import getCurrentActiveUser, getUserContext, createAccessToken, ACCESS_TOKEN_EXPIRE_MINUTES from modules.security.auth import getCurrentActiveUser, getUserContext, createAccessToken, ACCESS_TOKEN_EXPIRE_MINUTES
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
from modules.lucydomInterface import getLucydomInterface from modules.interfaces.lucydomInterface import getLucydomInterface
from modules.gatewayInterface import getGatewayInterface from modules.interfaces.gatewayInterface import getGatewayInterface
# Configure logger # Configure logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -5,11 +5,11 @@ from datetime import datetime
from dataclasses import dataclass from dataclasses import dataclass
# Import auth module # Import auth module
from modules.auth import getCurrentActiveUser, getUserContext from modules.security.auth import getCurrentActiveUser, getUserContext
# Import interfaces # Import interfaces
from modules.lucydomInterface import getLucydomInterface from modules.interfaces.lucydomInterface import getLucydomInterface
from modules.lucydomModel import Prompt from modules.interfaces.lucydomModel import Prompt
# Get all attributes of the model # Get all attributes of the model
def getModelAttributes(modelClass): def getModelAttributes(modelClass):

View file

@ -8,11 +8,11 @@ import time
import traceback import traceback
# Import auth module # Import auth module
from modules.auth import getCurrentActiveUser, getUserContext from modules.security.auth import getCurrentActiveUser, getUserContext
# Import interfaces # Import interfaces
from modules.gatewayInterface import getGatewayInterface from modules.interfaces.gatewayInterface import getGatewayInterface
from modules.gatewayModel import User from modules.interfaces.gatewayModel import User
# Set up logger # Set up logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -12,12 +12,12 @@ from dataclasses import dataclass
from datetime import datetime from datetime import datetime
# Import interfaces # Import interfaces
from modules.lucydomInterface import getLucydomInterface from modules.interfaces.lucydomInterface import getLucydomInterface
from modules.auth import getCurrentActiveUser, getUserContext from modules.security.auth import getCurrentActiveUser, getUserContext
from modules.workflowManager import getWorkflowManager from modules.workflow.workflowManager import getWorkflowManager
# Import models # Import models
from modules.lucydomModel import UserInputRequest from modules.interfaces.lucydomModel import UserInputRequest
# Configure logger # Configure logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -10,8 +10,8 @@ from fastapi.security import OAuth2PasswordBearer
from jose import JWTError, jwt from jose import JWTError, jwt
import logging import logging
from modules.gatewayInterface import getGatewayInterface from modules.interfaces.gatewayInterface import getGatewayInterface
from modules.configuration import APP_CONFIG from modules.shared.configuration import APP_CONFIG
# Get Config Data # Get Config Data
SECRET_KEY = APP_CONFIG.get("APP_JWT_SECRET_SECRET") SECRET_KEY = APP_CONFIG.get("APP_JWT_SECRET_SECRET")

View file

@ -0,0 +1,128 @@
"""
Agent Base Module.
Provides the base class for all chat agents.
Defines the standardized interface for task processing.
"""
import os
import logging
import uuid
from datetime import datetime
from typing import Dict, Any, List, Optional
from modules.shared.mimeUtils import isTextMimeType, determineContentEncoding
logger = logging.getLogger(__name__)
class AgentBase:
"""
Base class for all chat agents.
Defines the standardized interface for task processing.
"""
def __init__(self):
"""Initialize the base agent."""
self.name = "base"
self.label = "Base Agent"
self.description = "Base agent functionality"
self.capabilities = []
self.mydom = None
self.workflowManager = None # Will be set by workflow manager
def setDependencies(self, mydom=None):
"""Set external dependencies for the agent."""
self.mydom = mydom
def getAgentInfo(self) -> Dict[str, Any]:
"""
Return standardized information about the agent's capabilities.
Returns:
Dictionary with name, description, and capabilities
"""
return {
"name": self.name,
"description": self.description,
"capabilities": self.capabilities
}
async def processTask(self, task: Dict[str, Any]) -> Dict[str, Any]:
"""
Process a standardized task structure and return results.
This method must be implemented by all concrete agent classes.
Args:
task: A dictionary containing:
- taskId: Unique ID for this task
- workflowId: ID of the parent workflow
- prompt: The main instruction for the agent
- inputDocuments: List of document objects to process
- outputSpecifications: List of required output documents
- context: Additional contextual information including:
- workflow: The complete workflow object
- workflowRound: Current workflow round
- agentType: Type of agent
- timestamp: Task timestamp
- language: User language
Returns:
A dictionary containing:
- feedback: Text response explaining what the agent did
- documents: List of document objects created by the agent,
each containing a "base64Encoded" flag in addition to "label" and "content"
"""
# Base implementation - should be overridden by specialized agents
logger.warning(f"Agent {self.name} is using the default implementation of processTask")
return {
"feedback": f"The processTask method was not implemented by agent '{self.name}'.",
"documents": []
}
def determineBase64EncodingFlag(self, filename: str, content: Any, mimeType: str = None) -> bool:
"""Wrapper for the utility function"""
return determineContentEncoding(filename, content, mimeType)
def isTextMimeType(self, mimeType: str) -> bool:
"""Wrapper for the utility function"""
return isTextMimeType(mimeType)
def formatAgentDocumentOutput(self, label: str, content: Any, mimeType: str = None) -> Dict[str, Any]:
"""
Format agent output as a document.
Args:
label: Label for the document
content: Content of the document
mimeType: Optional MIME type for the document
"""
# Create document structure
doc = {
"id": str(uuid.uuid4()),
"name": label,
"ext": "txt", # Default extension
"data": content,
"base64Encoded": False,
"metadata": {
"isText": True
}
}
# Set MIME type if provided
if mimeType:
doc["mimeType"] = mimeType
# Update extension based on MIME type
if mimeType == "text/markdown":
doc["ext"] = "md"
elif mimeType == "text/html":
doc["ext"] = "html"
elif mimeType == "text/csv":
doc["ext"] = "csv"
elif mimeType == "application/json":
doc["ext"] = "json"
elif mimeType.startswith("image/"):
doc["ext"] = mimeType.split("/")[1]
doc["metadata"]["isText"] = False
elif mimeType == "application/pdf":
doc["ext"] = "pdf"
doc["metadata"]["isText"] = False
return doc

View file

@ -7,132 +7,11 @@ Optimized for the standardized task processing pattern.
import os import os
import logging import logging
import importlib import importlib
import uuid
from datetime import datetime
from typing import Dict, Any, List, Optional from typing import Dict, Any, List, Optional
from modules.mimeUtils import isTextMimeType, determineContentEncoding from .agentBase import AgentBase
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
"""
Updates to the AgentBase class in workflowAgentsRegistry.py to include base64Encoded flag handling.
"""
class AgentBase:
"""
Base class for all chat agents.
Defines the standardized interface for task processing.
"""
def __init__(self):
"""Initialize the base agent."""
self.name = "base-agent"
self.label = "(Template)"
self.description = "Basic agent functionality"
self.capabilities = []
self.mydom = None
self.workflowManager = None # Will be set by workflow manager
def setDependencies(self, mydom=None):
"""Set external dependencies for the agent."""
self.mydom = mydom
def getAgentInfo(self) -> Dict[str, Any]:
"""
Return standardized information about the agent's capabilities.
Returns:
Dictionary with name, description, and capabilities
"""
return {
"name": self.name,
"description": self.description,
"capabilities": self.capabilities
}
async def processTask(self, task: Dict[str, Any]) -> Dict[str, Any]:
"""
Process a standardized task structure and return results.
This method must be implemented by all concrete agent classes.
Args:
task: A dictionary containing:
- taskId: Unique ID for this task
- workflowId: ID of the parent workflow
- prompt: The main instruction for the agent
- inputDocuments: List of document objects to process
- outputSpecifications: List of required output documents
- context: Additional contextual information including:
- workflow: The complete workflow object
- workflowRound: Current workflow round
- agentType: Type of agent
- timestamp: Task timestamp
- language: User language
Returns:
A dictionary containing:
- feedback: Text response explaining what the agent did
- documents: List of document objects created by the agent,
each containing a "base64Encoded" flag in addition to "label" and "content"
"""
# Base implementation - should be overridden by specialized agents
logger.warning(f"Agent {self.name} is using the default implementation of processTask")
return {
"feedback": f"The processTask method was not implemented by agent '{self.name}'.",
"documents": []
}
def determineBase64EncodingFlag(self, filename: str, content: Any, mimeType: str = None) -> bool:
"""Wrapper for the utility function"""
return determineContentEncoding(filename, content, mimeType)
def isTextMimeType(self, mimeType: str) -> bool:
"""Wrapper for the utility function"""
return isTextMimeType(mimeType)
def formatAgentDocumentOutput(self, label: str, content: Any, mimeType: str = None) -> Dict[str, Any]:
"""
Format agent output as a document.
Args:
label: Label for the document
content: Content of the document
mimeType: Optional MIME type for the document
"""
# Create document structure
doc = {
"id": str(uuid.uuid4()),
"name": label,
"ext": "txt", # Default extension
"data": content,
"base64Encoded": False,
"metadata": {
"isText": True
}
}
# Set MIME type if provided
if mimeType:
doc["mimeType"] = mimeType
# Update extension based on MIME type
if mimeType == "text/markdown":
doc["ext"] = "md"
elif mimeType == "text/html":
doc["ext"] = "html"
elif mimeType == "text/csv":
doc["ext"] = "csv"
elif mimeType == "application/json":
doc["ext"] = "json"
elif mimeType.startswith("image/"):
doc["ext"] = mimeType.split("/")[1]
doc["metadata"]["isText"] = False
elif mimeType == "application/pdf":
doc["ext"] = "pdf"
doc["metadata"]["isText"] = False
return doc
class AgentRegistry: class AgentRegistry:
"""Central registry for all available agents in the system.""" """Central registry for all available agents in the system."""
@ -160,7 +39,7 @@ class AgentRegistry:
# List of agent modules to load # List of agent modules to load
agentModules = [] agentModules = []
agentDir = os.path.dirname(__file__) agentDir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "agents")
# Search the directory for agent modules # Search the directory for agent modules
for filename in os.listdir(agentDir): for filename in os.listdir(agentDir):
@ -177,7 +56,7 @@ class AgentRegistry:
for moduleName in agentModules: for moduleName in agentModules:
try: try:
# Import the module # Import the module
module = importlib.import_module(f"modules.{moduleName}") module = importlib.import_module(f"modules.agents.{moduleName}")
# Look for agent class or get_*_agent function # Look for agent class or get_*_agent function
agentName = moduleName.split("agent")[-1] agentName = moduleName.split("agent")[-1]

View file

@ -0,0 +1,10 @@
"""
Agent Registry Module.
Provides a central registry system for all available agents.
Optimized for the standardized task processing pattern.
"""
from .agentBase import AgentBase
from .agentRegistry import AgentRegistry, getAgentRegistry
__all__ = ['AgentBase', 'AgentRegistry', 'getAgentRegistry']

View file

@ -14,12 +14,12 @@ from datetime import datetime, timedelta
from typing import Dict, Any, List, Optional, Union, Tuple from typing import Dict, Any, List, Optional, Union, Tuple
import time import time
from modules.mimeUtils import isTextMimeType, determineContentEncoding from modules.shared.mimeUtils import isTextMimeType, determineContentEncoding
# Required imports # Required imports
from modules.workflowAgentsRegistry import getAgentRegistry from modules.workflow.agentRegistry import getAgentRegistry
from modules.lucydomInterface import getLucydomInterface as domInterface from modules.interfaces.lucydomInterface import getLucydomInterface as domInterface
from modules.documentProcessor import getDocumentContents from modules.workflow.documentProcessor import getDocumentContents
# Configure logger # Configure logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -461,7 +461,7 @@ JSON_OUTPUT = {{
"objFinalDocuments": ["label",...], # document label in the format 'filename.ext' "objFinalDocuments": ["label",...], # document label in the format 'filename.ext'
"objWorkplan": [ "objWorkplan": [
{{ {{
"agent": "agent_name", # Name of an available agent "agent": "agentName", # Name of an available agent
"prompt": "Specific instructions to the agent, that he knows what to do with which documents and which output to provide." "prompt": "Specific instructions to the agent, that he knows what to do with which documents and which output to provide."
"outputDocuments": [ "outputDocuments": [
{{ {{