Skip to content

Commit 6c3b9f4

Browse files
authored
Merge pull request #9 from JustAGhosT/tembo/refactor-repo-structure-dry-principles
Refactor LLM and Validation Modules
2 parents e246972 + 6dfa69e commit 6c3b9f4

46 files changed

Lines changed: 4509 additions & 1486 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codeflow_engine/actions/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@
186186
except ImportError:
187187
pass
188188

189+
# Create llm alias for backward compatibility (codeflow_engine.actions.llm)
190+
llm = None
191+
try:
192+
from codeflow_engine.actions.ai_actions import llm
193+
except ImportError:
194+
pass
195+
189196
# Platform
190197
PlatformDetector: type[Any] | None = None
191198
try:
@@ -223,6 +230,7 @@
223230
"generation",
224231
"git",
225232
"issues",
233+
"llm", # Backward compatibility alias for ai_actions.llm
226234
"maintenance",
227235
"platform",
228236
"quality",

codeflow_engine/actions/ai_actions/llm/__init__.py

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
"""
22
CODEFLOW LLM Package - Modular LLM provider system.
33
44
This package provides a unified interface for multiple LLM providers including:
@@ -12,7 +12,7 @@
1212
1313
Usage::
1414
15-
from codeflow_engine.actions.llm import get_llm_provider_manager, complete_chat
15+
from codeflow_engine.actions.ai_actions.llm import get_llm_provider_manager, complete_chat
1616
1717
# Get a manager instance
1818
manager = get_llm_provider_manager()
@@ -28,31 +28,41 @@
2828
import os
2929
from typing import Any
3030

31-
# Export base classes
32-
from codeflow_engine.actions.llm.base import BaseLLMProvider
31+
# Export base classes from core
32+
from codeflow_engine.core.llm import (
33+
BaseLLMProvider,
34+
LLMProviderRegistry,
35+
LLMResponse,
36+
OpenAICompatibleProvider,
37+
)
3338

3439
# Export manager
35-
from codeflow_engine.actions.llm.manager import ActionLLMProviderManager
40+
from codeflow_engine.actions.ai_actions.llm.manager import ActionLLMProviderManager
3641

3742
# Export providers
38-
from codeflow_engine.actions.llm.providers import (
43+
from codeflow_engine.actions.ai_actions.llm.providers import (
3944
AnthropicProvider,
45+
AzureOpenAIProvider,
4046
GroqProvider,
41-
MistralProvider,
4247
OpenAIProvider,
4348
PerplexityProvider,
4449
TogetherAIProvider,
50+
MISTRAL_AVAILABLE,
4551
)
4652

4753
# Export types
48-
from codeflow_engine.actions.llm.types import (
54+
from codeflow_engine.actions.ai_actions.llm.types import (
4955
LLMConfig,
5056
LLMProviderType,
51-
LLMResponse,
5257
Message,
5358
MessageRole,
5459
)
5560

61+
# Conditionally import MistralProvider
62+
MistralProvider = None
63+
if MISTRAL_AVAILABLE:
64+
from codeflow_engine.actions.ai_actions.llm.providers import MistralProvider
65+
5666

5767
# Global provider manager instance
5868
_provider_manager: ActionLLMProviderManager | None = None
@@ -63,7 +73,7 @@ def get_llm_provider_manager() -> ActionLLMProviderManager:
6373
Get or create the global LLM provider manager with configuration from environment variables.
6474
6575
Returns:
66-
LLMProviderManager: A configured instance of LLMProviderManager
76+
ActionLLMProviderManager: A configured instance of LLMProviderManager
6777
"""
6878
global _provider_manager
6979

@@ -166,26 +176,35 @@ def complete_chat(
166176
return manager.complete(request)
167177

168178

179+
# Backward compatibility alias
180+
LLMProviderManager = ActionLLMProviderManager
181+
182+
169183
# Export all public components
170184
__all__ = [
171-
"AnthropicProvider",
172185
# Base classes
173186
"BaseLLMProvider",
174-
"GroqProvider",
175-
"LLMConfig",
187+
"OpenAICompatibleProvider",
176188
# Manager
177189
"ActionLLMProviderManager",
190+
"LLMProviderManager", # Backward compatibility
191+
# Registry
192+
"LLMProviderRegistry",
193+
# Types
194+
"LLMConfig",
178195
"LLMProviderType",
179196
"LLMResponse",
180197
"Message",
181-
# Types
182198
"MessageRole",
183-
"MistralProvider",
184199
# Providers
200+
"AnthropicProvider",
201+
"AzureOpenAIProvider",
202+
"GroqProvider",
203+
"MistralProvider",
185204
"OpenAIProvider",
186205
"PerplexityProvider",
187206
"TogetherAIProvider",
188-
"complete_chat",
189207
# Factory functions
208+
"complete_chat",
190209
"get_llm_provider_manager",
191210
]
Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
"""
22
Abstract base class for LLM providers.
3-
"""
4-
5-
from abc import ABC, abstractmethod
6-
import os
7-
from typing import Any
8-
9-
from codeflow_engine.actions.llm.types import LLMResponse
103
4+
This module re-exports from codeflow_engine.core.llm for backwards compatibility.
5+
New code should import directly from codeflow_engine.core.llm.
6+
"""
117

12-
class BaseLLMProvider(ABC):
13-
"""Abstract base class for LLM providers."""
14-
15-
def __init__(self, config: dict[str, Any]) -> None:
16-
self.config = config
17-
self.api_key = config.get("api_key") or os.getenv(config.get("api_key_env", ""))
18-
self.base_url = config.get("base_url")
19-
self.default_model = config.get("default_model")
20-
self.name = config.get("name", self.__class__.__name__.lower().replace("provider", ""))
21-
22-
@abstractmethod
23-
def complete(self, request: dict[str, Any]) -> LLMResponse:
24-
"""Complete a chat conversation."""
8+
# Re-export from core for backwards compatibility
9+
from codeflow_engine.core.llm.base import BaseLLMProvider
2510

26-
@abstractmethod
27-
def is_available(self) -> bool:
28-
"""Check if the provider is properly configured and available."""
11+
__all__ = ["BaseLLMProvider"]

0 commit comments

Comments
 (0)