-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathfactory.py
45 lines (39 loc) · 1.72 KB
/
factory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from codegate.clients.clients import ClientType
from codegate.extract_snippets.body_extractor import (
AiderBodySnippetExtractor,
BodyCodeSnippetExtractor,
ClineBodySnippetExtractor,
ContinueBodySnippetExtractor,
KoduBodySnippetExtractor,
OpenInterpreterBodySnippetExtractor,
)
from codegate.extract_snippets.message_extractor import (
AiderCodeSnippetExtractor,
ClineCodeSnippetExtractor,
CodeSnippetExtractor,
DefaultCodeSnippetExtractor,
KoduCodeSnippetExtractor,
OpenInterpreterCodeSnippetExtractor,
)
class BodyCodeExtractorFactory:
@staticmethod
def create_snippet_extractor(detected_client: ClientType) -> BodyCodeSnippetExtractor:
mapping_client_extractor = {
ClientType.GENERIC: ContinueBodySnippetExtractor(),
ClientType.CLINE: ClineBodySnippetExtractor(),
ClientType.AIDER: AiderBodySnippetExtractor(),
ClientType.OPEN_INTERPRETER: OpenInterpreterBodySnippetExtractor(),
ClientType.KODU: KoduBodySnippetExtractor(),
}
return mapping_client_extractor.get(detected_client, ContinueBodySnippetExtractor())
class MessageCodeExtractorFactory:
@staticmethod
def create_snippet_extractor(detected_client: ClientType) -> CodeSnippetExtractor:
mapping_client_extractor = {
ClientType.GENERIC: DefaultCodeSnippetExtractor(),
ClientType.CLINE: ClineCodeSnippetExtractor(),
ClientType.AIDER: AiderCodeSnippetExtractor(),
ClientType.OPEN_INTERPRETER: OpenInterpreterCodeSnippetExtractor(),
ClientType.KODU: KoduCodeSnippetExtractor(),
}
return mapping_client_extractor.get(detected_client, DefaultCodeSnippetExtractor())