-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
191 changed files
with
6,750 additions
and
1,338 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
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
13 changes: 10 additions & 3 deletions
13
pkgs/community/swarmauri_community/document_stores/concrete/__init__.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,3 +1,10 @@ | ||
from swarmauri_community.document_stores.concrete.RedisDocumentStore import ( | ||
RedisDocumentStore, | ||
) | ||
from swarmauri.utils._lazy_import import _lazy_import | ||
|
||
documents_stores_files = [ | ||
("swarmauri_community.documents_stores.concrete.RedisDocumentStore", "RedisDocumentStore"), | ||
] | ||
|
||
for module_name, class_name in documents_stores_files: | ||
globals()[class_name] = _lazy_import(module_name, class_name) | ||
|
||
__all__ = [class_name for _, class_name in documents_stores_files] |
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
pkgs/community/swarmauri_community/embeddings/concrete/__init__.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,12 @@ | ||
from swarmauri.utils._lazy_import import _lazy_import | ||
|
||
|
||
embeddings_files = [ | ||
("swarmauri_community.embeddings.concrete.Doc2VecEmbedding", "Doc2VecEmbedding"), | ||
("swarmauri_community.embeddings.concrete.MlmEmbedding", "MlmEmbedding"), | ||
] | ||
|
||
for module_name, class_name in embeddings_files: | ||
globals()[class_name] = _lazy_import(module_name, class_name) | ||
|
||
__all__ = [class_name for _, class_name in embeddings_files] |
14 changes: 11 additions & 3 deletions
14
pkgs/community/swarmauri_community/llms/concrete/__init__.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,4 +1,12 @@ | ||
from swarmauri_community.llms.concrete.LeptonAIImgGenModel import LeptonAIImgGenModel | ||
from swarmauri_community.llms.concrete.LeptonAIModel import LeptonAIModel | ||
from swarmauri.utils._lazy_import import _lazy_import | ||
|
||
__all__ = ["LeptonAIImgGenModel", "LeptonAIModel"] | ||
llms_files = [ | ||
("swarmauri_community.llms.concrete.LeptonAIImgGenModel", "LeptonAIImgGenModel"), | ||
("swarmauri_community.llms.concrete.LeptonAIModel", "LeptonAIModel"), | ||
("swarmauri_community.llms.concrete.PytesseractImg2TextModel", "PytesseractImg2TextModel"), | ||
] | ||
|
||
for module_name, class_name in llms_files: | ||
globals()[class_name] = _lazy_import(module_name, class_name) | ||
|
||
__all__ = [class_name for _, class_name in llms_files] |
17 changes: 11 additions & 6 deletions
17
pkgs/community/swarmauri_community/measurements/concrete/__init__.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,6 +1,11 @@ | ||
from swarmauri_community.measurements.concrete.MutualInformationMeasurement import ( | ||
MutualInformationMeasurement, | ||
) | ||
from swarmauri_community.measurements.concrete.TokenCountEstimatorMeasurement import ( | ||
TokenCountEstimatorMeasurement, | ||
) | ||
from swarmauri.utils._lazy_import import _lazy_import | ||
|
||
measurement_files = [ | ||
("swarmauri_community.measurements.concrete.MutualInformationMeasurement", "MutualInformationMeasurement"), | ||
("swarmauri_community.measurements.concrete.TokenCountEstimatorMeasurement", "TokenCountEstimatorMeasurement"), | ||
] | ||
|
||
for module_name, class_name in measurement_files: | ||
globals()[class_name] = _lazy_import(module_name, class_name) | ||
|
||
__all__ = [class_name for _, class_name in measurement_files] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 16 additions & 3 deletions
19
pkgs/community/swarmauri_community/parsers/concrete/__init__.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,3 +1,16 @@ | ||
from swarmauri_community.parsers.concrete.FitzPdfParser import PDFtoTextParser | ||
from swarmauri_community.parsers.concrete.PyPDF2Parser import PyPDF2Parser | ||
from swarmauri_community.parsers.concrete.PyPDFTKParser import PyPDFTKParser | ||
from swarmauri.utils._lazy_import import _lazy_import | ||
|
||
parsers_files = [ | ||
("swarmauri_community.parsers.concrete.BERTEmbeddingParser", "BERTEmbeddingParser"), | ||
("swarmauri_community.parsers.concrete.EntityRecognitionParser", "EntityRecognitionParser"), | ||
("swarmauri_community.parsers.concrete.FitzPdfParser", "FitzPdfParser"), | ||
("swarmauri_community.parsers.concrete.PyPDF2Parser", "PyPDF2Parser"), | ||
("swarmauri_community.parsers.concrete.PyPDFTKParser", "PyPDFTKParser"), | ||
("swarmauri_community.parsers.concrete.TextBlobNounParser", "TextBlobNounParser"), | ||
("swarmauri_community.parsers.concrete.TextBlobSentenceParser", "TextBlobSentenceParser"), | ||
] | ||
|
||
for module_name, class_name in parsers_files: | ||
globals()[class_name] = _lazy_import(module_name, class_name) | ||
|
||
__all__ = [class_name for _, class_name in parsers_files] |
13 changes: 9 additions & 4 deletions
13
pkgs/community/swarmauri_community/retrievers/concrete/__init__.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,5 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
from swarmauri.utils._lazy_import import _lazy_import | ||
|
||
from swarmauri_community.retrievers.concrete.RedisDocumentRetriever import ( | ||
RedisDocumentRetriever, | ||
) | ||
retriever_files = [ | ||
("swarmauri_community.retrievers.concrete.RedisDocumentRetriever", "RedisDocumentRetriever"), | ||
] | ||
|
||
for module_name, class_name in retriever_files: | ||
globals()[class_name] = _lazy_import(module_name, class_name) | ||
|
||
__all__ = [class_name for _, class_name in retriever_files] |
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 @@ | ||
from swarmauri_community.state.concrete import * |
69 changes: 69 additions & 0 deletions
69
pkgs/community/swarmauri_community/state/concrete/ClipboardState.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,69 @@ | ||
import pyperclip | ||
from typing import Dict, Any | ||
from swarmauri.state.base.StateBase import StateBase | ||
|
||
|
||
class ClipboardState(StateBase): | ||
""" | ||
A concrete implementation of StateBase that uses the system clipboard to store and retrieve state data. | ||
""" | ||
|
||
def read(self) -> Dict[str, Any]: | ||
""" | ||
Reads the current state from the clipboard as a dictionary. | ||
""" | ||
try: | ||
clipboard_content = pyperclip.paste() | ||
# Ensure the clipboard contains valid data (e.g., a JSON string that can be parsed) | ||
if clipboard_content: | ||
return eval( | ||
clipboard_content | ||
) # Replace eval with JSON for safer parsing | ||
return {} | ||
except Exception as e: | ||
raise ValueError(f"Failed to read state from clipboard: {e}") | ||
|
||
def write(self, data: Dict[str, Any]) -> None: | ||
""" | ||
Replaces the current state with the given data by copying it to the clipboard. | ||
""" | ||
try: | ||
pyperclip.copy( | ||
str(data) | ||
) # Convert dictionary to string for clipboard storage | ||
except Exception as e: | ||
raise ValueError(f"Failed to write state to clipboard: {e}") | ||
|
||
def update(self, data: Dict[str, Any]) -> None: | ||
""" | ||
Updates the current state with the given data by merging with clipboard content. | ||
""" | ||
try: | ||
current_state = self.read() | ||
current_state.update(data) | ||
self.write(current_state) | ||
except Exception as e: | ||
raise ValueError(f"Failed to update state on clipboard: {e}") | ||
|
||
def reset(self) -> None: | ||
""" | ||
Resets the clipboard state to an empty dictionary. | ||
""" | ||
try: | ||
self.write({}) | ||
except Exception as e: | ||
raise ValueError(f"Failed to reset clipboard state: {e}") | ||
|
||
def deep_copy(self) -> "ClipboardState": | ||
""" | ||
Creates a deep copy of the current state. In this context, simply returns a new ClipboardState with the same clipboard data. | ||
""" | ||
try: | ||
current_state = self.read() | ||
new_instance = ClipboardState() | ||
new_instance.write(current_state) | ||
return new_instance | ||
except Exception as e: | ||
raise ValueError( | ||
f"Failed to create a deep copy of the clipboard state: {e}" | ||
) |
Oops, something went wrong.