- Added EveAI Client to project
- Improvements to EntitlementsDomain & Services - Prechecks in Document domain - Add audit information to LicenseUsage
This commit is contained in:
0
eveai_client/platform/config/__init__.py
Normal file
0
eveai_client/platform/config/__init__.py
Normal file
44
eveai_client/platform/config/config.py
Normal file
44
eveai_client/platform/config/config.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import os
|
||||
|
||||
|
||||
class Config:
|
||||
"""Base configuration for the EveAI client."""
|
||||
# EveAI API settings
|
||||
TENANT_ID = os.environ.get('EVEAI_TENANT_ID', '2') # Default tenant ID
|
||||
API_KEY = os.environ.get('EVEAI_API_KEY', 'EveAI-4479-9311-1356-6142-6703-2915-6079-6640') # Default API key
|
||||
API_BASE_URL = os.environ.get('EVEAI_API_BASE_URL', 'http://macstudio.ask-eve-ai-local.com:8080/api')
|
||||
|
||||
# Specialist settings
|
||||
# List of available specialists (ID, name, description)
|
||||
SPECIALISTS = [
|
||||
{
|
||||
'id': 3,
|
||||
'name': 'RAG Specialist',
|
||||
'description': 'Answers questions on Evie / Ask Eve AI'
|
||||
},
|
||||
{
|
||||
'id': 2,
|
||||
'name': 'SPIN Specialist',
|
||||
'description': 'Answers questions and tries to dive deeper into context of customer'
|
||||
},
|
||||
# Add more specialists as needed
|
||||
]
|
||||
|
||||
# Cache settings
|
||||
# Instead of SQLite, we'll use in-memory caching with an expiry time
|
||||
TOKEN_CACHE_EXPIRY = 3600 # 1 hour
|
||||
CONFIG_CACHE_EXPIRY = 86400 # 24 hours
|
||||
|
||||
# UI settings
|
||||
WINDOW_TITLE = 'EveAI Client'
|
||||
WINDOW_WIDTH = 1200
|
||||
WINDOW_HEIGHT = 800
|
||||
WINDOW_MIN_WIDTH = 800
|
||||
WINDOW_MIN_HEIGHT = 600
|
||||
|
||||
|
||||
def get_config(config_name='default'):
|
||||
configs = {
|
||||
'default': Config,
|
||||
}
|
||||
return configs.get(config_name)
|
||||
53
eveai_client/platform/config/config_manager.py
Normal file
53
eveai_client/platform/config/config_manager.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from typing import Dict, Any
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from flask import Flask
|
||||
|
||||
from eveai_client.platform.config.config import Config
|
||||
|
||||
|
||||
class ConfigManager:
|
||||
"""Manages configuration and caching of specialist configurations."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize the configuration manager."""
|
||||
self.specialist_configs = {}
|
||||
self.config_cache_expiry = Config.CONFIG_CACHE_EXPIRY
|
||||
|
||||
def init_app(self, app: Flask) -> None:
|
||||
self.config_cache_expiry = app.config["CONFIG_CACHE_EXPIRY"]
|
||||
|
||||
def get_specialist_config(self, specialist_id: int) -> Dict[str, Any]:
|
||||
"""Get specialist configuration, either from cache or from API."""
|
||||
cached_config = self._get_cached_config(specialist_id)
|
||||
if cached_config:
|
||||
return cached_config
|
||||
return {} # Empty config, will be fetched by API client
|
||||
|
||||
def save_specialist_config(self, specialist_id: int, config: Dict[str, Any]) -> None:
|
||||
"""Save specialist configuration to cache."""
|
||||
self.specialist_configs[specialist_id] = {
|
||||
'config': config,
|
||||
'updated_at': datetime.utcnow()
|
||||
}
|
||||
|
||||
def _get_cached_config(self, specialist_id: int) -> Dict[str, Any]:
|
||||
"""Get cached specialist configuration if valid."""
|
||||
if specialist_id not in self.specialist_configs:
|
||||
return {}
|
||||
|
||||
cached_entry = self.specialist_configs[specialist_id]
|
||||
updated_at = cached_entry['updated_at']
|
||||
|
||||
if datetime.utcnow() - updated_at > timedelta(seconds=self.config_cache_expiry):
|
||||
return {} # Cache expired
|
||||
|
||||
return cached_entry['config']
|
||||
|
||||
def clear_cache(self) -> None:
|
||||
"""Clear all cached configurations."""
|
||||
self.specialist_configs = {}
|
||||
|
||||
def get_available_specialists(self) -> list:
|
||||
"""Get list of available specialists from config."""
|
||||
return Config.SPECIALISTS
|
||||
Reference in New Issue
Block a user