Skip to main content

**workspacex** is a Python library for managing AIGC (AI-Generated Content) artifacts. It provides a collaborative workspace environment for handling multiple artifacts with features like version control, update notifications, artifact management, and pluggable storage and embedding backends.

Project description

workspacex

workspacex is a Python library for managing AIGC (AI-Generated Content) artifacts. It provides a collaborative workspace environment for handling multiple artifacts with features like version control, update notifications, artifact management, and pluggable storage and embedding backends.


Features

  • Artifact Management: Create, update, and manage different types of artifacts (text, code, etc.)
  • Version Control: Track changes and maintain version history for artifacts
  • Workspace Organization: Group related artifacts in collaborative workspaces
  • Event Handling: Observer pattern for artifact creation and updates
  • Storage Backends: Local file system and S3-compatible storage (via s3fs)
  • Embedding Backends: OpenAI-compatible and Ollama embedding support
  • Type Safety: Built with Pydantic for robust data validation
  • Async Support: Asynchronous operations for better performance
  • Extensible: Easy to add new storage, embedding, extractor, and reranker backends

Project Structure

workspacex/
  src/
    workspacex/   # Main package code
      artifact.py
      code_artifact.py
      workspace.py
      observer.py
      storage/
        local.py
        s3.py
        base.py
      embedding/
        openai_compatible.py
        ollama.py
        base.py
      extractor/
        noval_extractor.py
        base.py
      reranker/
        base.py
      utils/
        timeit.py
    examples/     # Example scripts
      embeddings/
      data/
      novel_chapters/

Environment Setup

  1. Install dependencies

    poetry install
    
  2. Activate the conda environment

    conda activate rl
    

Usage

Basic Example

import asyncio
import logging

from workspacex import WorkSpace, ArtifactType, get_observer, on_artifact_create

@on_artifact_create
async def handle_artifact_create(artifact):
    logging.info(f"Artifact created: {artifact.artifact_id}")

if __name__ == '__main__':
    workspace = WorkSpace.from_local_storages(workspace_id="demo")
    asyncio.run(workspace.create_artifact(ArtifactType.TEXT, "artifact_001"))

Artifacts and workspace data will be stored in data/workspaces.

Storage Backends

  • Local: Default, stores data in the local file system.
    from workspacex.storage.local import LocalPathRepository
    repo = LocalPathRepository("data/workspaces/demo")
    
  • S3: Store artifacts in S3-compatible storage.
    from workspacex.storage.s3 import S3Repository
    repo = S3Repository(storage_path="demo", bucket="your-bucket", s3_kwargs={"key": "...", "secret": "..."})
    

Embedding Backends

  • OpenAI-Compatible:
    from workspacex.embedding.openai_compatible import OpenAICompatibleEmbeddings, EmbeddingsConfig
    config = EmbeddingsConfig(api_key="sk-...", base_url="https://api.openai.com/v1", model_name="text-embedding-ada-002")
    embedder = OpenAICompatibleEmbeddings(config)
    
  • Ollama:
    from workspacex.embedding.ollama import OllamaEmbeddings, OllamaConfig
    config = OllamaConfig(model="nomic-embed-text", base_url="http://localhost:11434")
    embedder = OllamaEmbeddings(config)
    

Example Scripts

  • See src/examples/ for ready-to-run scripts:
    • noval_example.py
    • embeddings/openai_example.py
    • embeddings/ollama_embedding_example.py
    • image_examples.py

Run an example:

export PYTHONPATH=src
python src/examples/embeddings/openai_example.py

Notes

  • All source code is under src/.
  • Make sure to activate the correct conda environment before using Poetry commands or running code.
  • If you see ModuleNotFoundError: No module named 'workspacex', ensure your PYTHONPATH includes src.
  • Storage and embedding backends are pluggable and extensible.
  • For S3 support, install s3fs and configure credentials as needed.

Let me know if you want to add more details, such as advanced usage, API docs, or contribution guidelines!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

workspacex-0.1.2.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

workspacex-0.1.2-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file workspacex-0.1.2.tar.gz.

File metadata

  • Download URL: workspacex-0.1.2.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.16 Darwin/24.3.0

File hashes

Hashes for workspacex-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e2af79cf845e2273d47841df087367009b3f370714da8b438208537eab7c4e55
MD5 f18fb7461812eb6f44ba43268d4c57f9
BLAKE2b-256 bd3e77490bca6c7177980a08c2f01a0c86589f3dad45da825bc9ef10b3fda569

See more details on using hashes here.

File details

Details for the file workspacex-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: workspacex-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.16 Darwin/24.3.0

File hashes

Hashes for workspacex-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22b29fa942f637956c85b80e72ab79286654c80851b45fea7828f0f6d5fca83b
MD5 b8c884588009ef43efb8d8f7da0b4080
BLAKE2b-256 7de80deb2d2b7b796d6f62e9b9f9e688e76b516a1e9ef6c6dce2e78e546fd8dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page