ciyidogan commited on
Commit
5e9eccb
·
verified ·
1 Parent(s): c8c1133

Delete llm_startup.py

Browse files
Files changed (1) hide show
  1. llm_startup.py +0 -102
llm_startup.py DELETED
@@ -1,102 +0,0 @@
1
- """
2
- Flare – LLM startup notifier (Refactored)
3
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
- Projeler açılırken LLM provider'a startup çağrısı yapar.
5
- """
6
-
7
- from __future__ import annotations
8
- import threading
9
- import asyncio
10
- from typing import Dict, Any
11
- from logger import log_info, log_error, log_warning, log_debug
12
- from config_provider import ConfigProvider, ProjectConfig, VersionConfig
13
- from llm_factory import LLMFactory
14
-
15
- def _select_live_version(p: ProjectConfig) -> VersionConfig | None:
16
- """Yayınlanmış en güncel versiyonu getir."""
17
- published = [v for v in p.versions if v.published]
18
- return max(published, key=lambda v: v.no) if published else None
19
-
20
- async def notify_startup_async():
21
- """Notify LLM provider about project startups (async version)"""
22
- cfg = ConfigProvider.get()
23
-
24
- # Check if LLM provider requires repo info
25
- llm_provider_def = cfg.global_config.get_provider_config(
26
- "llm",
27
- cfg.global_config.llm_provider.name
28
- )
29
-
30
- if not llm_provider_def or not llm_provider_def.requires_repo_info:
31
- log_info(f"ℹ️ LLM provider '{cfg.global_config.llm_provider.name}' does not require startup notification")
32
- return
33
-
34
- # Create LLM provider instance
35
- try:
36
- llm_provider = LLMFactory.create_provider()
37
- except Exception as e:
38
- log_error("❌ Failed to create LLM provider for startup", e)
39
- return
40
-
41
- # Notify for each enabled project
42
- enabled_projects = [p for p in cfg.projects if p.enabled and not getattr(p, 'deleted', False)]
43
-
44
- if not enabled_projects:
45
- log_info("ℹ️ No enabled projects found for startup notification")
46
- return
47
-
48
- for project in enabled_projects:
49
- version = _select_live_version(project)
50
- if not version:
51
- log_info(f"⚠️ No published version found for project '{project.name}', skipping startup")
52
- continue
53
-
54
- # Build project config - version.id yerine version.no kullan
55
- project_config = {
56
- "name": project.name,
57
- "version_no": version.no, # version_id yerine version_no
58
- "repo_id": version.llm.repo_id,
59
- "generation_config": version.llm.generation_config,
60
- "use_fine_tune": version.llm.use_fine_tune,
61
- "fine_tune_zip": version.llm.fine_tune_zip
62
- }
63
-
64
- try:
65
- log_info(f"🚀 Notifying LLM provider startup for project '{project.name}'...")
66
- success = await llm_provider.startup(project_config)
67
-
68
- if success:
69
- log_info(f"✅ LLM provider acknowledged startup for '{project.name}'")
70
- else:
71
- log_info(f"⚠️ LLM provider startup failed for '{project.name}'")
72
-
73
- except Exception as e:
74
- log_error(f"❌ Error during startup notification for '{project.name}'", e)
75
-
76
- def notify_startup():
77
- """Synchronous wrapper for async startup notification"""
78
- # Create new event loop for thread
79
- loop = asyncio.new_event_loop()
80
- asyncio.set_event_loop(loop)
81
-
82
- try:
83
- loop.run_until_complete(notify_startup_async())
84
- finally:
85
- loop.close()
86
-
87
- def run_in_thread():
88
- """Start startup notification in background thread"""
89
- cfg = ConfigProvider.get()
90
-
91
- # Check if provider requires startup
92
- llm_provider_def = cfg.global_config.get_provider_config(
93
- "llm",
94
- cfg.global_config.llm_provider.name
95
- )
96
-
97
- if not llm_provider_def or not llm_provider_def.requires_repo_info:
98
- log_info(f"🤖 {cfg.global_config.llm_provider.name} - Startup notification not required")
99
- return
100
-
101
- log_info("🚀 Starting LLM provider startup notification thread...")
102
- threading.Thread(target=notify_startup, daemon=True).start()