Fix configs validation #66
@@ -6,27 +6,31 @@ from app.interface import *
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# =====================
|
||||
load_dotenv()
|
||||
configs = AppConfig.load()
|
||||
# =====================
|
||||
|
||||
chat = ChatManager()
|
||||
gradio = chat.gradio_build_interface()
|
||||
_app, local_url, share_url = gradio.launch(server_name="0.0.0.0", server_port=configs.port, quiet=True, prevent_thread_lock=True, share=configs.gradio_share)
|
||||
logging.info(f"UPO AppAI Chat is running on {share_url or local_url}")
|
||||
|
||||
try:
|
||||
telegram = TelegramApp()
|
||||
telegram.add_miniapp_url(share_url)
|
||||
telegram.run()
|
||||
except AssertionError as e:
|
||||
# =====================
|
||||
load_dotenv()
|
||||
configs = AppConfig.load()
|
||||
# =====================
|
||||
|
||||
chat = ChatManager()
|
||||
gradio = chat.gradio_build_interface()
|
||||
_app, local_url, share_url = gradio.launch(server_name="0.0.0.0", server_port=configs.port, quiet=True, prevent_thread_lock=True, share=configs.gradio_share)
|
||||
logging.info(f"UPO AppAI Chat is running on {share_url or local_url}")
|
||||
|
||||
try:
|
||||
logging.warning(f"Telegram bot could not be started: {e}")
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_forever()
|
||||
except KeyboardInterrupt:
|
||||
logging.info("Shutting down due to KeyboardInterrupt")
|
||||
finally:
|
||||
gradio.close()
|
||||
telegram = TelegramApp()
|
||||
telegram.add_miniapp_url(share_url)
|
||||
telegram.run()
|
||||
except AssertionError as e:
|
||||
try:
|
||||
logging.warning(f"Telegram bot could not be started: {e}")
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_forever()
|
||||
except KeyboardInterrupt:
|
||||
logging.info("Shutting down due to KeyboardInterrupt")
|
||||
finally:
|
||||
gradio.close()
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Application failed to start: {e}")
|
||||
|
||||
@@ -152,9 +152,12 @@ class AgentsConfigs(BaseModel):
|
||||
def validate_defaults(self, configs: 'AppConfig') -> None:
|
||||
"""
|
||||
Validate that the default models and strategy exist in the provided configurations.
|
||||
If any default is not found, a ValueError is raised.
|
||||
Args:
|
||||
models: ModelsConfig instance containing all available models.
|
||||
strategies: list of Strategy instances containing all available strategies.
|
||||
Raises:
|
||||
ValueError if any default model or strategy is not found.
|
||||
"""
|
||||
try:
|
||||
configs.get_strategy_by_name(self.strategy)
|
||||
|
||||
Reference in New Issue
Block a user