Files
unstract/docker/sample.compose.override.yaml
Hari John Kuriakose bbe55e80bc Add SDK v1 into unstract package namespace (#1482)
* * Add feature flag for sdk_v1
* Add sdk1 to unstract common ns
* Update backend deps
* Fix dev essentials container names
* Update sample compose override

* * Fix imports in llm
* Refactor provider args validation

* [feat] add embedding, vectordb adapters in sdk1
[feat] add file storage, tool, util, platform, prompt modules in sdk1
[feat] integrate sdk1 in backend under feature flag

* feat: integrate sdk1 in platform service

* [feat] integrate sdk1 with filesystem core package

* refactor: conditionally import sdk1 in platform svc

* refactor: conditionally import sdk1 in backend

* feat: integrate sdk1 with unstract core tool registry pkg

* feat: integrate sdk1 with tools
feat: add x2txt adapter to sdk1
feat: add adapter and tools helpers to sdk1

* feat: integrate sdk1 with prompt service
feat: add llm no-op adapter in sdk1
feat: add utils in sdk1

* Regenerated uv.lock for backend since it had issues

* fix: cleanup unnecessary conditionals

* Removed import which caused issues in prompt_studio_helper.py

* fix: embedding init
feat: unified embedding  interface powered by litellm

* fix: correct platform helper imports

* Fixed variations of feature flag differing between sdk pypi and local sdk

* Fixed inconsistent version of "aiohttp" in backend's uv.lock

* fix: resolve circular imports by restructuring SDK modules

- Move audit.py and usage_handler.py from utils/ to parent directory
- Remove re-exports from utils/__init__.py to eliminate circular dependencies
- Update imports across codebase to be explicit:
  * Direct imports from utils.common for Utils and log_elapsed
  * Direct import from audit module for Audit class
  * Direct import from utils.tool for ToolUtils
- Fix imports in backend services, prompt-service, and tools

Files moved:
- unstract/sdk1/utils/audit.py → unstract/sdk1/audit.py
- unstract/sdk1/utils/usage_handler.py → unstract/sdk1/usage_handler.py

* Refactor SDK1 adapters: migrate to versioned directories

- Rename embedding/ to embedding1/ for all adapter types
- Rename llm/ to llm1/ directory structure
- Add new base1.py classes for adapter foundations
- Update backend adapter processor to support new structure
- Update import paths and references in embedding.py and llm.py

* deps: add requirements
feat: bump litellm version
chore: generate uv lock

* * Remove v0 embedding and llm adapters
* Add v1 embedding and llm adapters
* Add unified litellm powered embedding and llm interfaces
* Fix internal v1 imports

* Remove debug logs

* feat: add missing modules

* fix: module imports

* fix: handle adapter metadata

* feat: add support for adapter instance id

* fix: kw arguments for embedding entrypoint

* fix: module invocation

* feat: add embedding compat layer
fix: tool binding for adapter instance id
fix: context window size integration
fix: callabck manager for embedding compat

* fix: embedding compat layer async apis

* fix: missing imports

* fix: callback manager for embedding compat

* feat: remove llmwhisperer v1 adapter
feat: remove deprecated code
feat: add metrics capture to llm adapters
feat: add llm usage reporting
feat: add llm response post processing
fix: handling platform kwargs
fix: minor integration issues

* fix: type hints

* feat: make platform api key optional if no tool

* fix: cleanup llmwhisperer v1 imports

* fix: minor integration issues

* fix: minor integration issues

* fix: minor integration issues

* fix: minor integration issues

* style: improve readability

* style: improve readability
fix: minor integration issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed Azure openai LLM connector not working.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: integrate unstract-sdk1 as a dependency into prompt service

- Add unstract-sdk1as a dependency to prompt-service pyproject.toml
- Update prompt Dockerfile to include sdk1 package in build

* Fixed extra params passed to bedrock llm adapter and added support for thinking

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat(sdk1): upgrade litellm to v1.76.0 for consistency in params for LLMs

- Update litellm dependency from v1.74.7 to v1.76.0 in pyproject.toml
- Add new uv.lock file for sdk1 package dependency management
- Update backend and prompt-service uv.lock files for dependency consistency

* - Add litellm.drop_params=True to filter unsupported model parameters
- Fixed vertex AI llms connector not working
- Modified params to include thinking capabilities for bedrock llm.
- Update OpenAI adapter configuration schema (Previously it was the schema for OpenAI embedding).

* refactor(sdk1): separate LLM and embedding parameter classes

- Split BaseParameters into BaseChatCompletionParameters and BaseEmbeddingParameters
- Rename OpenAIParameters to OpenAILLMParameters for clarity
- Add OpenAIEmbeddingParameters for embedding-specific configurations
- Update all embedding adapters to use new parameter classes(*provider*EmbeddingParameters)
- Remove batch_embed_size from bedrock.json configuration file since bedrock doesn't support it.
- Improve embedding.py with better parameter handling and litellm.drop_params
- Add fallback for platform API key when tool is not available
- Fix default parameter handling in EmbeddingCompat class

* Added unstract-sdk1 as a dependency to platform-service

* Fixed cost mot being displayed for prompt runs in prompt-studio

* Fixed issues with create profile manager not working properly in prompt-studio

* fix(sdk1): resolve compatibility issues with single_pass_extraction plugin

  - Fix LLM response structure compatibility by returning LLMResponseCompat objects
  - Merge usage_kwargs into platform_kwargs for proper audit/usage tracking
  - Add adapter_instance_id to platform_kwargs similar to original SDK
  - Update test_connection method to use LLMResponseCompat.text attribute
  - Ensure usage data (run_id, llm_usage_reason, adapter_instance_id) is properly passed to audit system

  This resolves TypeError and AttributeError issues when using SDK1 with plugins
  that expect unstract-sdk compatible response structures and usage tracking.

* - Added feature flag imports for some file which imported sdk0(llama-index)
- Added get_model_name method in sdk1 llm.py
- moved model_name sanitization from cost_calculation.py to audit.py(sdk1)

* Revert unnecessary empty line

Signed-off-by: Hari John Kuriakose <hari@zipstack.com>

* added reasoning capabilities and fixed issue with validating model name

* - Removed .gitignore .pre-commit-config.yaml
- Removed commented out code in pyproject.toml in sdk1 folder

* Revert "- Removed .gitignore .pre-commit-config.yaml"

This reverts commit 8a2ed67ef8f4e7134fb7eb735b0dac40be67ebf1.

* - Removed .gitignore .pre-commit-config.yaml
- Removed commented code in pyproject.toml in sdk1

* Reverted rabbitmq hostname to `unstract-rabbit` in dev-essentials.yaml

* Imported LLMWhispererv1 into sdkv1

* Removed commented out supabase deps in pyproject.toml

* Added support for sdk1 in tools

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Generate lock files for the latest unstract-sdk v0.77.3

* Addressed pre-commits issues with typing annotation and long lines of code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed ruff fails in pre-commit check

* Fixed pre-commit ruff failures in sdk1 directory and modified ruff rules in pyproject.toml

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed sonar cloud reliability issues.

---------

Signed-off-by: Hari John Kuriakose <hari@zipstack.com>
Co-authored-by: pk-zipstack <praveen@zipstack.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-09-29 14:28:08 +05:30

197 lines
6.0 KiB
YAML

# Refer https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/
# Minimize celery workers to reduce memory usage of Unstract (aids development)
services:
worker:
command: "-A backend worker --loglevel=info -Q celery,celery_api_deployments,celery_periodic_logs,celery_log_task_queue,file_processing,api_file_processing,file_processing_callback,api_file_processing_callback --autoscale=${WORKER_AUTOSCALE}"
worker-logging:
profiles:
- high_memory
worker-file-processing:
profiles:
- high_memory
worker-file-processing-callback:
profiles:
- high_memory
# Watch configuration
# Refer https://docs.docker.com/compose/how-tos/file-watch/
frontend:
build:
dockerfile: docker/dockerfiles/frontend.Dockerfile
context: ..
target: development
env_file:
- ../frontend/.env
develop:
watch:
# Sync the frontend directory with the container
- action: sync
path: ../frontend/
target: /app
ignore: node_modules/
# Rebuild when dependencies change
- action: rebuild
path: ../frontend/package-lock.json
- action: rebuild
path: ../frontend/package.json
backend:
build:
dockerfile: docker/dockerfiles/backend.Dockerfile
context: ..
entrypoint: ["bash", "-c"]
command: [
"source .venv/bin/activate && \
uv sync --all-groups && \
python /tmp/debugpy --listen 0.0.0.0:5678 .venv/bin/gunicorn \
--bind 0.0.0.0:8000 \
--workers 2 \
--threads 4 \
--worker-class gthread \
--log-level debug \
--timeout 900 \
--access-logfile - \
--reload --graceful-timeout 5 backend.wsgi:application"
]
develop:
watch:
# Sync the backend directory with the container
- action: sync+restart
path: ../backend/
target: /app
ignore: [.venv/, __pycache__/, "*.pyc", .pytest_cache/, .mypy_cache/]
- action: sync+restart
path: ../unstract/
target: /unstract
ignore: [.venv/, __pycache__/, "*.pyc", .pytest_cache/, .mypy_cache/]
# Rebuild when dependencies change
- action: rebuild
path: ./dockerfiles/*
- action: rebuild
path: ../backend/uv.lock
## Uncomment below lines to use local version of unstract-sdk
## NOTE: Restart the containers on code change though
# environment:
# - PYTHONPATH=/unstract-sdk/src
# volumes:
# - <path_to_unstract_sdk>/unstract-sdk:/unstract-sdk
runner:
build:
dockerfile: docker/dockerfiles/runner.Dockerfile
context: ..
entrypoint: ["bash", "-c"]
command: [
"source .venv/bin/activate && \
uv sync --all-groups && \
python /tmp/debugpy --listen 0.0.0.0:5681 .venv/bin/gunicorn \
--bind 0.0.0.0:5002 \
--workers 2 \
--threads 2 \
--worker-class gthread \
--log-level debug \
--timeout 900 \
--access-logfile - \
--reload --graceful-timeout 5 unstract.runner:app"
]
develop:
watch:
# Sync the runner directory with the container
- action: sync+restart
path: ../runner/
target: /app
ignore: [.venv/, __pycache__/, "*.pyc", .pytest_cache/, .mypy_cache/]
# Rebuild when dependencies change
- action: rebuild
path: ../runner/uv.lock
platform-service:
build:
dockerfile: docker/dockerfiles/platform.Dockerfile
context: ..
entrypoint: ["bash", "-c"]
command: [
"source .venv/bin/activate && \
uv sync --all-groups && \
python /tmp/debugpy --listen 0.0.0.0:5679 .venv/bin/gunicorn \
--bind 0.0.0.0:3001 \
--workers 2 \
--threads 2 \
--worker-class gevent \
--log-level debug \
--timeout 900 \
--access-logfile - \
--reload --graceful-timeout 5 unstract.platform_service.run:app"
]
develop:
watch:
# Sync the platform-service directory with the container
- action: sync+restart
path: ../platform-service/
target: /app
ignore: [.venv/, __pycache__/, "*.pyc", .pytest_cache/, .mypy_cache/]
# Rebuild when dependencies change
- action: rebuild
path: ../platform-service/uv.lock
prompt-service:
build:
dockerfile: docker/dockerfiles/prompt.Dockerfile
context: ..
entrypoint: ["bash", "-c"]
command: [
"source .venv/bin/activate && \
uv sync --all-groups && \
python /tmp/debugpy --listen 0.0.0.0:5680 .venv/bin/gunicorn \
--bind 0.0.0.0:3003 \
--workers 2 \
--threads 2 \
--worker-class gthread \
--log-level debug \
--timeout 900 \
--access-logfile - \
--reload --graceful-timeout 5 unstract.prompt_service.run:app"
]
develop:
watch:
# Sync the prompt-service directory with the container
- action: sync+restart
path: ../prompt-service/
target: /app
ignore: [.venv/, __pycache__/, "*.pyc", .pytest_cache/, .mypy_cache/]
# Rebuild when dependencies change
- action: rebuild
path: ../prompt-service/uv.lock
x2text-service:
build:
dockerfile: docker/dockerfiles/x2text.Dockerfile
context: ..
entrypoint: ["bash", "-c"]
command: [
"source .venv/bin/activate && \
uv sync --all-groups && \
python /tmp/debugpy --listen 0.0.0.0:5682 .venv/bin/gunicorn \
--bind 0.0.0.0:3004 \
--workers 2 \
--threads 2 \
--worker-class gthread \
--log-level debug \
--timeout 900 \
--access-logfile - \
--reload --graceful-timeout 5 unstract.x2text_service.run:app"
]
develop:
watch:
# Sync the x2text-service directory with the container
- action: sync+restart
path: ../x2text-service/
target: /app
ignore: [.venv/, __pycache__/, "*.pyc", .pytest_cache/, .mypy_cache/]
# Rebuild when dependencies change
- action: rebuild
path: ../x2text-service/uv.lock