Fix configs validation #66
@@ -6,27 +6,31 @@ from app.interface import *
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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:
|
try:
|
||||||
telegram = TelegramApp()
|
# =====================
|
||||||
telegram.add_miniapp_url(share_url)
|
load_dotenv()
|
||||||
telegram.run()
|
configs = AppConfig.load()
|
||||||
except AssertionError as e:
|
# =====================
|
||||||
|
|
||||||
|
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:
|
try:
|
||||||
logging.warning(f"Telegram bot could not be started: {e}")
|
telegram = TelegramApp()
|
||||||
loop = asyncio.new_event_loop()
|
telegram.add_miniapp_url(share_url)
|
||||||
asyncio.set_event_loop(loop)
|
telegram.run()
|
||||||
loop.run_forever()
|
except AssertionError as e:
|
||||||
except KeyboardInterrupt:
|
try:
|
||||||
logging.info("Shutting down due to KeyboardInterrupt")
|
logging.warning(f"Telegram bot could not be started: {e}")
|
||||||
finally:
|
loop = asyncio.new_event_loop()
|
||||||
gradio.close()
|
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:
|
def validate_defaults(self, configs: 'AppConfig') -> None:
|
||||||
"""
|
"""
|
||||||
Validate that the default models and strategy exist in the provided configurations.
|
Validate that the default models and strategy exist in the provided configurations.
|
||||||
|
If any default is not found, a ValueError is raised.
|
||||||
Args:
|
Args:
|
||||||
models: ModelsConfig instance containing all available models.
|
models: ModelsConfig instance containing all available models.
|
||||||
strategies: list of Strategy instances containing all available strategies.
|
strategies: list of Strategy instances containing all available strategies.
|
||||||
|
Raises:
|
||||||
|
ValueError if any default model or strategy is not found.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
configs.get_strategy_by_name(self.strategy)
|
configs.get_strategy_by_name(self.strategy)
|
||||||
|
|||||||
Reference in New Issue
Block a user