Skip to content

Commit

Permalink
Merge 6ac16f5 into 764fed6
Browse files Browse the repository at this point in the history
  • Loading branch information
cobycloud authored Dec 18, 2024
2 parents 764fed6 + 6ac16f5 commit 0fc5e34
Show file tree
Hide file tree
Showing 191 changed files with 6,750 additions and 1,338 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/increment_version_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
- name: Increment versions in pyproject.toml
run: |
set -x
echo "Incrementing versions..."
find . -name "pyproject.toml" | while read -r pyproject; do
echo "Processing $pyproject"
# Extract current version
CURRENT_VERSION=$(python -c "
import tomlkit
Expand All @@ -43,31 +43,30 @@ jobs:
print(f'Error reading version from {pyproject}: {e}', end='')
exit(1)
")
echo "Extracted CURRENT_VERSION: $CURRENT_VERSION"
if [ -z "$CURRENT_VERSION" ]; then
echo "Error: Could not extract the current version from $pyproject"
cat "$pyproject"
continue
fi
# Increment version
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/(.*)-dev.*/\1/')
DEV_PART=$(echo "$CURRENT_VERSION" | grep -oE 'dev[0-9]+$' | grep -oE '[0-9]+')
# Fallback if no DEV_PART is found
if [ -z "$DEV_PART" ]; then
DEV_PART=0
fi
NEW_DEV_PART=$((DEV_PART + 1))
NEW_VERSION="${BASE_VERSION}-dev${NEW_DEV_PART}"
echo "Updating version from $CURRENT_VERSION to $NEW_VERSION"
done
- name: Commit changes
run: |
git config user.name "github-actions[bot]"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sequence_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
- uses: actions/checkout@v4

- name: Wait for swarmauri
run: sleep 60
run: sleep 120

- name: Set up Python 3.12
uses: actions/setup-python@v5
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/test_changed_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ jobs:
run-tests:
needs: detect-changed-files
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
if: ${{ needs.detect-changed-files.outputs.matrix != '[]' }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -134,9 +137,21 @@ jobs:
cd pkgs/${{ matrix.package_tests.package }}
poetry install --no-cache --all-extras -vv
- name: Run all tests for the package
- name: Run tests and save results
run: |
echo "Running tests for package: ${{ matrix.package_tests.package }}"
echo "Test files: ${{ matrix.package_tests.tests }}"
cd pkgs/${{ matrix.package_tests.package }}
poetry run pytest ${{ matrix.package_tests.tests }}
poetry run pytest ${{ matrix.package_tests.tests }} --tb=short --json-report --json-report-file=pytest_results.json || true
- name: Process test results and manage issues
if: always()
env:
DEEPINFRA_API_KEY: ${{ secrets.DEEPINFRA_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
cd pkgs/swarmauri # Change to the directory containing pyproject.toml
poetry run python ../../scripts/rag_issue_manager.py --results-file=pytest_results.json --package=${{ matrix.package_tests.package }}
106 changes: 65 additions & 41 deletions pkgs/community/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "swarmauri-community"
version = "0.5.2.dev20"
version = "0.5.3.dev5"
description = "This repository includes Swarmauri community components."
authors = ["Jacob Stewart <jacob@swarmauri.com>"]
license = "Apache-2.0"
Expand All @@ -15,48 +15,74 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
captcha = "*"
chromadb = "*"
duckdb = "*"
folium = "*"
gensim = "*"
#google-generativeai = "*"
gradio = "*"
leptonai = "0.22.0"
neo4j = "*"
nltk = "*"
#openai = "^1.52.0"
pandas = "*"
psutil = "*"
pygithub = "*"
python-dotenv = "*"
qrcode = "*"
redis = "^4.0"
scikit-learn="^1.4.2"
swarmauri = "==0.5.2"
textstat = "*"
transformers = ">=4.45.0"
typing_extensions = "*"
tiktoken = "*"
pymupdf = "*"
annoy = "*"
qdrant_client = "*"
weaviate = "*"
pinecone-client = { version = "*", extras = ["grpc"] }
PyPDF2 = "*"
pypdftk = "*"
weaviate-client = "*"
protobuf = "^3.20.0"
# Pacmap requires specific version of numba
#numba = ">=0.59.0"
#pacmap = "==0.7.3"
captcha = "^0.6.0"

# We should remove and only rely on httpx
requests = "^2.32.3"

chromadb = { version = "^0.5.17", optional = true }
duckdb = { version = "^1.1.1", optional = true }
folium = { version = "^0.18.0", optional = true }
gensim = { version = "^4.3.3", optional = true }
gradio = { version = "^5.4.0", optional = true }
leptonai = { version = "^0.22.0", optional = true }
neo4j = { version = "^5.25.0", optional = true }
nltk = { version = "^3.9.1", optional = true }
pandas = "^2.2.3"
psutil = { version = "^6.1.0", optional = true }
pygithub = { version = "^2.4.0", optional = true }
qrcode = { version = "^8.0", optional = true }
redis = { version = "^4.0", optional = true }
swarmauri = "==0.5.3.dev5"
textstat = { version = "^0.7.4", optional = true }
transformers = { version = ">=4.45.0", optional = true }
typing_extensions = "^4.12.2"
tiktoken = { version = "^0.8.0", optional = true }
PyMuPDF = { version = "^1.24.12", optional = true }
annoy = { version = "^1.17.3", optional = true }
qdrant-client = { version = "^1.12.0", optional = true }
pinecone-client = { version = "^5.0.1", optional = true, extras = ["grpc"] }
pypdf = { version = "^5.0.1", optional = true }
pypdftk = { version = "^0.5", optional = true }
weaviate-client = { version = "^4.9.2", optional = true }
textblob = { version = "^0.18.0", optional = true }
torch = { version = "^2.4.1", optional = true}
scikit-learn = { version = "^1.5.2", optional = true }
#protobuf = { version = "^3.20.0", optional = true }

[tool.poetry.extras]
# Grouped optional dependencies
nlp = ["nltk", "gensim", "textstat", "textblob", "torch", "scikit-learn"]
ml_toolkits = ["transformers", "annoy"]
visualization = ["folium"]
storage = ["redis", "duckdb", "neo4j", "chromadb", "qdrant-client", "weaviate-client", "pinecone-client"]
document_processing = ["pypdf", "PyMuPDF", "pypdftk"]
cloud_integration = ["psutil", "qrcode", "pygithub"]
gradio = ["gradio"]
model_clients = ["leptonai"]
tiktoken = ["tiktoken"]

# Full installation
full = [
"nltk", "gensim", "textstat", "textblob", "torch", "scikit-learn",
"transformers", "annoy",
"folium",
"redis", "duckdb", "neo4j", "chromadb", "qdrant-client", "weaviate-client", "pinecone-client",
"pypdf", "PyMuPDF", "pypdftk",
"psutil", "qrcode", "pygithub",
"gradio",
"leptonai",
"tiktoken"
]

[tool.poetry.dev-dependencies]
flake8 = "^7.0" # Add flake8 as a development dependency
pytest = "^8.0" # Ensure pytest is also added if you run tests
flake8 = "^7.0"
pytest = "^8.0"
pytest-asyncio = ">=0.24.0"
pytest-xdist = "^3.6.1"
pytest-json-report = "^1.5.0"
python-dotenv = "*"
requests = "^2.32.3"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand All @@ -70,12 +96,10 @@ markers = [
"unit: Unit tests",
"integration: Integration tests",
"acceptance: Acceptance tests",
"experimental: Experimental tests",
"experimental: Experimental tests"
]

log_cli = true
log_cli_level = "INFO"
log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
log_cli_date_format = "%Y-%m-%d %H:%M:%S"

asyncio_default_fixture_loop_scope = "function"
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.
12 changes: 12 additions & 0 deletions pkgs/community/swarmauri_community/embeddings/concrete/__init__.py
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 pkgs/community/swarmauri_community/llms/concrete/__init__.py
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]
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]
19 changes: 16 additions & 3 deletions pkgs/community/swarmauri_community/parsers/concrete/__init__.py
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]
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]
1 change: 1 addition & 0 deletions pkgs/community/swarmauri_community/state/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from swarmauri_community.state.concrete import *
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}"
)
Loading

0 comments on commit 0fc5e34

Please sign in to comment.