mirror of
https://github.com/SHOGGOTH-SECTOR/sica-fondt.git
synced 2026-08-01 08:30:20 +00:00
Place useful parts of the surrounding repos into sica-fondt by layer, per the
body model (Ada = membrane; brain/endocrine/capabilities/knowledge non-Ada):
- brain/ LLM reasoning + providers (dapr, hermes, MoMoA)
- capabilities/ REPRAG sidecars: hermes tools/skills, dapr tools, parallel
dispatch, A51 channels, and the OSINT cluster
- knowledge/ LORAG corpus: 754 cyber-skills, agency personas, secure-coding,
MITRE ATT&CK data
- reference/ defensive threat-reference (C3, shhbruh doc) + AdaYaml parser
License handling: AGPL sources (worldosint, advanced_evolution, mercury,
Reticulum) and GPL DeTTECT are SPEC-only clean-room/port descriptions — no
copyleft code copied. MIT/Apache/data parts copied as working trees.
Safety: shhbruh escape/persistence material and C3 covert-C2 kept as reference
only, not wired into the running organism. See CONSOLIDATION.md.
https://claude.ai/code/session_01UehUqEXXJJCsHoA4voCU5c
102 lines
3.5 KiB
Python
102 lines
3.5 KiB
Python
#
|
|
# Copyright 2026 The Dapr Authors
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
|
|
from dapr_agents.types.llm import ElevenLabsClientConfig
|
|
from dapr_agents.llm.base import LLMClientBase
|
|
from typing import Any, Optional
|
|
from pydantic import Field
|
|
import os
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ElevenLabsClientBase(LLMClientBase):
|
|
"""
|
|
Base class for managing ElevenLabs LLM clients.
|
|
Handles client initialization, configuration, and shared logic specific to the ElevenLabs API.
|
|
"""
|
|
|
|
api_key: Optional[str] = Field(
|
|
default=None,
|
|
description="API key for authenticating with the ElevenLabs API. Defaults to environment variables 'ELEVENLABS_API_KEY' or 'ELEVEN_API_KEY'.",
|
|
)
|
|
base_url: Optional[str] = Field(
|
|
default="https://api.elevenlabs.io",
|
|
description="Base URL for the ElevenLabs API endpoints.",
|
|
)
|
|
|
|
def model_post_init(self, __context: Any) -> None:
|
|
"""
|
|
Initializes private attributes and performs any post-validation setup.
|
|
|
|
This includes setting up provider-specific attributes such as configuration and client instances.
|
|
"""
|
|
self._provider = "elevenlabs"
|
|
|
|
# Use environment variable if `api_key` is not explicitly provided
|
|
if self.api_key is None:
|
|
self.api_key = os.getenv("ELEVENLABS_API_KEY") or os.getenv(
|
|
"ELEVEN_API_KEY"
|
|
)
|
|
|
|
if self.api_key is None:
|
|
raise ValueError(
|
|
"API key is required. Set it explicitly or in the 'ELEVENLABS_API_KEY' or 'ELEVEN_API_KEY' environment variable."
|
|
)
|
|
|
|
# Initialize configuration and client
|
|
self._config = self.get_config()
|
|
self._client = self.get_client()
|
|
logger.info("ElevenLabs client initialized successfully.")
|
|
|
|
return super().model_post_init(__context)
|
|
|
|
def get_config(self) -> ElevenLabsClientConfig:
|
|
"""
|
|
Returns the configuration object for the ElevenLabs API client.
|
|
"""
|
|
return ElevenLabsClientConfig(api_key=self.api_key, base_url=self.base_url)
|
|
|
|
def get_client(self) -> Any:
|
|
"""
|
|
Initializes and returns the ElevenLabs API client.
|
|
|
|
This method sets up the client using the provided configuration.
|
|
"""
|
|
try:
|
|
from elevenlabs import ElevenLabs
|
|
except ImportError as e:
|
|
raise ImportError(
|
|
"The 'elevenlabs' package is required but not installed. Install it with 'pip install elevenlabs'."
|
|
) from e
|
|
|
|
config = self.config
|
|
|
|
logger.info("Initializing ElevenLabs API client...")
|
|
return ElevenLabs(api_key=config.api_key, base_url=config.base_url)
|
|
|
|
@property
|
|
def config(self) -> ElevenLabsClientConfig:
|
|
"""
|
|
Provides access to the ElevenLabs API client configuration.
|
|
"""
|
|
return self._config
|
|
|
|
@property
|
|
def client(self) -> Any:
|
|
"""
|
|
Provides access to the ElevenLabs API client instance.
|
|
"""
|
|
return self._client
|