From 276fd86ecb4e4ee898eb29eac331dd4e58b68084 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Thu, 12 Dec 2024 13:25:13 -0500 Subject: [PATCH] More fixes for missing packages --- .readthedocs.yaml | 64 ++++++++++++++++++++++++++++++- docs/api/conf.py | 62 ++++++++++++++++++++++++++++++ docs/api/index.rst | 1 + docs/api/requirements-base.txt | 36 +++++++++++++++++ docs/api/requirements-playht.txt | 3 ++ docs/api/requirements-riva.txt | 3 ++ docs/api/requirements.txt | 6 --- docs/api/rtd-test.sh | 36 +++++++++++++++++ pyproject.toml | 2 +- src/pipecat/services/anthropic.py | 7 ++-- 10 files changed, 208 insertions(+), 12 deletions(-) create mode 100644 docs/api/requirements-base.txt create mode 100644 docs/api/requirements-playht.txt create mode 100644 docs/api/requirements-riva.txt delete mode 100644 docs/api/requirements.txt create mode 100755 docs/api/rtd-test.sh diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 667e789d9..ea03b508e 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -4,12 +4,74 @@ build: os: ubuntu-22.04 tools: python: '3.12' + jobs: + pre_build: + # Commands to run before the build + - python -m pip install --upgrade pip + - pip install wheel setuptools + post_create_environment: + # Install system dependencies required by some packages + - apt-get update + - apt-get install -y portaudio19-dev python3-pyaudio + post_build: + # Commands to run after the build + - echo "Build completed" sphinx: configuration: docs/api/conf.py + fail_on_warning: false # Set to true if you want builds to fail on warnings python: install: - - requirements: docs/api/requirements.txt + - requirements: docs/api/requirements-base.txt + # Try to install Riva first, fall back to PlayHT if it fails + - requirements: docs/api/requirements-riva.txt || true + - requirements: docs/api/requirements-playht.txt || true - method: pip path: . + extra_requirements: + - anthropic + - assemblyai + - aws + - azure + - canonical + - cartesia + - deepgram + - elevenlabs + - fal + - fireworks + - gladia + - google + - grok + - groq + - krisp + - langchain + - livekit + - lmnt + - moondream + - nim + - noisereduce + - openai + - openpipe + - silero + - simli + - soundfile + - websocket + - whisper + +formats: + - pdf + - epub + - htmlzip + +# Cache dependencies to speed up builds +search: + ranking: + api/*: 5 + getting-started/*: 4 + guides/*: 3 + +# Configure submodules if needed +submodules: + include: all + recursive: true diff --git a/docs/api/conf.py b/docs/api/conf.py index 843700feb..ad969df8c 100644 --- a/docs/api/conf.py +++ b/docs/api/conf.py @@ -40,6 +40,31 @@ autodoc_default_options = { "show-inheritance": True, } +# Mock imports for optional dependencies +autodoc_mock_imports = [ + "riva", + "livekit", + "pyht", + "anthropic", + "assemblyai", + "boto3", + "azure", + "cartesia", + "deepgram", + "elevenlabs", + "fal", + "gladia", + "google", + "krisp", + "langchain", + "lmnt", + "noisereduce", + "openai", + "openpipe", + "simli", + "soundfile", +] + # HTML output settings html_theme = "sphinx_rtd_theme" html_static_path = ["_static"] @@ -47,6 +72,39 @@ autodoc_typehints = "description" html_show_sphinx = False +def verify_modules(): + """Verify that required modules are available.""" + required_modules = { + "services": [ + "assemblyai", + "aws", + "cartesia", + "deepgram", + "google", + "lmnt", + "riva", + "simli", + ], + "serializers": ["livekit"], + "vad": ["silero", "vad_analyzer"], + } + + missing = [] + for category, modules in required_modules.items(): + for module in modules: + try: + __import__(f"pipecat.{category}.{module}") + logger.info(f"Successfully imported pipecat.{category}.{module}") + except ImportError as e: + missing.append(f"pipecat.{category}.{module}") + logger.warning( + f"Optional module not available: pipecat.{category}.{module} - {str(e)}" + ) + + if missing: + logger.warning(f"Some optional modules are not available: {missing}") + + def clean_title(title: str) -> str: """Automatically clean module titles.""" # Remove everything after space (like 'module', 'processor', etc.) @@ -151,3 +209,7 @@ def setup(app): except Exception as e: logger.error(f"Error generating API documentation: {e}", exc_info=True) + + +# Run module verification +verify_modules() diff --git a/docs/api/index.rst b/docs/api/index.rst index a878c0c10..a8cba911d 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -22,6 +22,7 @@ Core Components * :mod:`Frames ` * :mod:`Processors ` * :mod:`Pipeline ` +* :mod:`Services ` Audio Processing ~~~~~~~~~~~~~~~~ diff --git a/docs/api/requirements-base.txt b/docs/api/requirements-base.txt new file mode 100644 index 000000000..6739a1962 --- /dev/null +++ b/docs/api/requirements-base.txt @@ -0,0 +1,36 @@ +# Sphinx dependencies +sphinx>=8.1.3 +sphinx-rtd-theme +sphinx-markdown-builder +sphinx-autodoc-typehints +toml + +# Install all extras individually to ensure they're properly resolved +pipecat-ai[anthropic] +pipecat-ai[assemblyai] +pipecat-ai[aws] +pipecat-ai[azure] +pipecat-ai[canonical] +pipecat-ai[cartesia] +pipecat-ai[deepgram] +pipecat-ai[elevenlabs] +pipecat-ai[fal] +pipecat-ai[fireworks] +pipecat-ai[gladia] +pipecat-ai[google] +pipecat-ai[grok] +pipecat-ai[groq] +pipecat-ai[krisp] +pipecat-ai[langchain] +pipecat-ai[livekit] +pipecat-ai[lmnt] +pipecat-ai[moondream] +pipecat-ai[nim] +pipecat-ai[noisereduce] +pipecat-ai[openai] +pipecat-ai[openpipe] +pipecat-ai[silero] +pipecat-ai[simli] +pipecat-ai[soundfile] +pipecat-ai[websocket] +pipecat-ai[whisper] \ No newline at end of file diff --git a/docs/api/requirements-playht.txt b/docs/api/requirements-playht.txt new file mode 100644 index 000000000..1f0bc24ea --- /dev/null +++ b/docs/api/requirements-playht.txt @@ -0,0 +1,3 @@ +# Force specific grpcio version for PlayHT +grpcio>=1.68.0 +pipecat-ai[playht] \ No newline at end of file diff --git a/docs/api/requirements-riva.txt b/docs/api/requirements-riva.txt new file mode 100644 index 000000000..6bd4c69f9 --- /dev/null +++ b/docs/api/requirements-riva.txt @@ -0,0 +1,3 @@ +# Force specific grpcio version for Riva +grpcio==1.65.4 +pipecat-ai[riva] \ No newline at end of file diff --git a/docs/api/requirements.txt b/docs/api/requirements.txt deleted file mode 100644 index d57bcd00f..000000000 --- a/docs/api/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -sphinx>=8.1.3 -sphinx-rtd-theme -sphinx-markdown-builder -sphinx-autodoc-typehints -toml -pipecat-ai[anthropic,assemblyai,aws,azure,canonical,cartesia,deepgram,elevenlabs,fal,fireworks,gladia,google,grok,groq,krisp,langchain,lmnt,moondream,nim,noisereduce,openai,openpipe,playht,riva,silero,simli,soundfile,websocket,whisper] \ No newline at end of file diff --git a/docs/api/rtd-test.sh b/docs/api/rtd-test.sh new file mode 100755 index 000000000..87d8880b4 --- /dev/null +++ b/docs/api/rtd-test.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -e + +# Configuration +DOCS_DIR=$(pwd) +PROJECT_ROOT=$(cd ../../ && pwd) +TEST_DIR="/tmp/rtd-test-$(date +%Y%m%d_%H%M%S)" + +echo "Creating test directory: $TEST_DIR" +mkdir -p "$TEST_DIR" +cd "$TEST_DIR" + +# Create single virtual environment +python -m venv venv +source venv/bin/activate + +echo "Installing base dependencies..." +pip install --upgrade pip wheel setuptools +pip install -r "$DOCS_DIR/requirements-base.txt" + +# Try to install optional dependencies, but don't fail if they don't work +echo "Installing Riva dependencies..." +pip install -r "$DOCS_DIR/requirements-riva.txt" || echo "Failed to install Riva dependencies" + +echo "Installing PlayHT dependencies..." +pip install -r "$DOCS_DIR/requirements-playht.txt" || echo "Failed to install PlayHT dependencies" + +echo "Building documentation..." +cd "$DOCS_DIR" +sphinx-build -b html . "_build/html" + +echo "Build complete. Check _build/html directory for output." + +# Print installed packages for verification +echo "Installed packages:" +pip freeze \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f3f7d6050..f8b122580 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,11 +66,11 @@ openpipe = [ "openpipe~=4.38.0" ] playht = [ "pyht~=0.1.8", "websockets~=13.1" ] riva = [ "nvidia-riva-client~=2.17.0" ] silero = [ "onnxruntime~=1.20.1" ] +simli = [ "simli-ai~=0.1.7"] soundfile = [ "soundfile~=0.12.1" ] together = [ "openai~=1.57.2" ] websocket = [ "websockets~=13.1", "fastapi~=0.115.0" ] whisper = [ "faster-whisper~=1.1.0" ] -simli = [ "simli-ai~=0.1.7"] [tool.setuptools.packages.find] # All the following settings are optional: diff --git a/src/pipecat/services/anthropic.py b/src/pipecat/services/anthropic.py index 48102eda7..f0c033375 100644 --- a/src/pipecat/services/anthropic.py +++ b/src/pipecat/services/anthropic.py @@ -11,7 +11,7 @@ import json import re from asyncio import CancelledError from dataclasses import dataclass -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List, Optional, Union from loguru import logger from PIL import Image @@ -75,8 +75,7 @@ class AnthropicContextAggregatorPair: class AnthropicLLMService(LLMService): - """ - This class implements inference with Anthropic's AI models. + """This class implements inference with Anthropic's AI models. Can provide a custom client via the `client` kwarg, allowing you to use `AsyncAnthropicBedrock` and `AsyncAnthropicVertex` clients @@ -328,7 +327,7 @@ class AnthropicLLMContext(OpenAILLMContext): tools: list[dict] | None = None, tool_choice: dict | None = None, *, - system: str | NotGiven = NOT_GIVEN, + system: Union[str, NotGiven] = NOT_GIVEN, ): super().__init__(messages=messages, tools=tools, tool_choice=tool_choice)