Skip to content

Commit

Permalink
More fixes for missing packages
Browse files Browse the repository at this point in the history
  • Loading branch information
markbackman committed Dec 12, 2024
1 parent b5d5a0e commit 276fd86
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 12 deletions.
64 changes: 63 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
62 changes: 62 additions & 0 deletions docs/api/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,71 @@
"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"]
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.)
Expand Down Expand Up @@ -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()
1 change: 1 addition & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Core Components
* :mod:`Frames <pipecat.frames>`
* :mod:`Processors <pipecat.processors>`
* :mod:`Pipeline <pipecat.pipeline>`
* :mod:`Services <pipecat.services>`

Audio Processing
~~~~~~~~~~~~~~~~
Expand Down
36 changes: 36 additions & 0 deletions docs/api/requirements-base.txt
Original file line number Diff line number Diff line change
@@ -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]
3 changes: 3 additions & 0 deletions docs/api/requirements-playht.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Force specific grpcio version for PlayHT
grpcio>=1.68.0
pipecat-ai[playht]
3 changes: 3 additions & 0 deletions docs/api/requirements-riva.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Force specific grpcio version for Riva
grpcio==1.65.4
pipecat-ai[riva]
6 changes: 0 additions & 6 deletions docs/api/requirements.txt

This file was deleted.

36 changes: 36 additions & 0 deletions docs/api/rtd-test.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions src/pipecat/services/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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
Expand Down Expand Up @@ -75,8 +75,7 @@ def assistant(self) -> "AnthropicAssistantContextAggregator":


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
Expand Down Expand Up @@ -328,7 +327,7 @@ def __init__(
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)

Expand Down

0 comments on commit 276fd86

Please sign in to comment.