-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move imports to top of files (#850)
* chore: move import to the top of create_app.py * refactor: move imports to top of SourceDocument.py * chore: move Imports to top of Strategies.py * chore: move imports to top of Strategies.py and remove circular dependency * chore: split OrchestrationStrategy symbol to it's own file * chore: move imports to top of Strategies.py
- Loading branch information
Showing
18 changed files
with
68 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
code/backend/batch/utilities/document_chunking/ChunkingStrategy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from enum import Enum | ||
|
||
|
||
class ChunkingStrategy(Enum): | ||
LAYOUT = "layout" | ||
PAGE = "page" | ||
FIXED_SIZE_OVERLAP = "fixed_size_overlap" | ||
PARAGRAPH = "paragraph" | ||
|
||
|
||
class ChunkingSettings: | ||
def __init__(self, chunking: dict): | ||
self.chunking_strategy = ChunkingStrategy(chunking["strategy"]) | ||
self.chunk_size = chunking["size"] | ||
self.chunk_overlap = chunking["overlap"] | ||
|
||
def __eq__(self, other: object) -> bool: | ||
if isinstance(self, other.__class__): | ||
return ( | ||
self.chunking_strategy == other.chunking_strategy | ||
and self.chunk_size == other.chunk_size | ||
and self.chunk_overlap == other.chunk_overlap | ||
) | ||
else: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
code/backend/batch/utilities/document_chunking/FixedSizeOverlap.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 5 additions & 33 deletions
38
code/backend/batch/utilities/document_chunking/Strategies.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,18 @@ | ||
from enum import Enum | ||
|
||
|
||
class ChunkingStrategy(Enum): | ||
LAYOUT = "layout" | ||
PAGE = "page" | ||
FIXED_SIZE_OVERLAP = "fixed_size_overlap" | ||
PARAGRAPH = "paragraph" | ||
from .ChunkingStrategy import ChunkingStrategy | ||
from .Layout import LayoutDocumentChunking | ||
from .Page import PageDocumentChunking | ||
from .FixedSizeOverlap import FixedSizeOverlapDocumentChunking | ||
from .Paragraph import ParagraphDocumentChunking | ||
|
||
|
||
def get_document_chunker(chunking_strategy: str): | ||
if chunking_strategy == ChunkingStrategy.LAYOUT.value: | ||
from .Layout import LayoutDocumentChunking | ||
|
||
return LayoutDocumentChunking() | ||
elif chunking_strategy == ChunkingStrategy.PAGE.value: | ||
from .Page import PageDocumentChunking | ||
|
||
return PageDocumentChunking() | ||
elif chunking_strategy == ChunkingStrategy.FIXED_SIZE_OVERLAP.value: | ||
from .FixedSizeOverlap import FixedSizeOverlapDocumentChunking | ||
|
||
return FixedSizeOverlapDocumentChunking() | ||
elif chunking_strategy == ChunkingStrategy.PARAGRAPH.value: | ||
from .Paragraph import ParagraphDocumentChunking | ||
|
||
return ParagraphDocumentChunking() | ||
else: | ||
raise Exception(f"Unknown chunking strategy: {chunking_strategy}") | ||
|
||
|
||
class ChunkingSettings: | ||
def __init__(self, chunking: dict): | ||
self.chunking_strategy = ChunkingStrategy(chunking["strategy"]) | ||
self.chunk_size = chunking["size"] | ||
self.chunk_overlap = chunking["overlap"] | ||
|
||
def __eq__(self, other: object) -> bool: | ||
if isinstance(self, other.__class__): | ||
return ( | ||
self.chunking_strategy == other.chunking_strategy | ||
and self.chunk_size == other.chunk_size | ||
and self.chunk_overlap == other.chunk_overlap | ||
) | ||
else: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
code/backend/batch/utilities/helpers/DocumentChunkingHelper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
code/backend/batch/utilities/orchestrator/OrchestrationStrategy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from enum import Enum | ||
|
||
|
||
class OrchestrationStrategy(Enum): | ||
OPENAI_FUNCTION = "openai_function" | ||
LANGCHAIN = "langchain" | ||
SEMANTIC_KERNEL = "semantic_kernel" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,15 @@ | ||
from enum import Enum | ||
|
||
|
||
class OrchestrationStrategy(Enum): | ||
OPENAI_FUNCTION = "openai_function" | ||
LANGCHAIN = "langchain" | ||
SEMANTIC_KERNEL = "semantic_kernel" | ||
from .OrchestrationStrategy import OrchestrationStrategy | ||
from .OpenAIFunctions import OpenAIFunctionsOrchestrator | ||
from .LangChainAgent import LangChainAgent | ||
from .SemanticKernel import SemanticKernelOrchestrator | ||
|
||
|
||
def get_orchestrator(orchestration_strategy: str): | ||
if orchestration_strategy == OrchestrationStrategy.OPENAI_FUNCTION.value: | ||
from .OpenAIFunctions import OpenAIFunctionsOrchestrator | ||
|
||
return OpenAIFunctionsOrchestrator() | ||
elif orchestration_strategy == OrchestrationStrategy.LANGCHAIN.value: | ||
from .LangChainAgent import LangChainAgent | ||
|
||
return LangChainAgent() | ||
elif orchestration_strategy == OrchestrationStrategy.SEMANTIC_KERNEL.value: | ||
from .SemanticKernel import SemanticKernelOrchestrator | ||
|
||
return SemanticKernelOrchestrator() | ||
else: | ||
raise Exception(f"Unknown orchestration strategy: {orchestration_strategy}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters