File size: 1,819 Bytes
1397957
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from typing import Dict, Any, List, Optional, AsyncGenerator
import os
import json

from .provider import ModelInfo, Message, StreamChunk, ToolCall
from .openai import OpenAIProvider


class BlabladorProvider(OpenAIProvider):
    
    def __init__(self, api_key: Optional[str] = None):
        super().__init__(api_key=api_key or os.environ.get("BLABLADOR_API_KEY"))
        self._base_url = "https://api.helmholtz-blablador.fz-juelich.de/v1"
    
    @property
    def id(self) -> str:
        return "blablador"
    
    @property
    def name(self) -> str:
        return "Blablador"
    
    @property
    def models(self) -> Dict[str, ModelInfo]:
        return {
            "alias-large": ModelInfo(
                id="alias-large",
                name="Blablador Large",
                provider_id="blablador",
                context_limit=32768,
                output_limit=4096,
                supports_tools=True,
                supports_streaming=True,
                cost_input=0.0,
                cost_output=0.0,
            ),
            "alias-fast": ModelInfo(
                id="alias-fast",
                name="Blablador Fast",
                provider_id="blablador",
                context_limit=8192,
                output_limit=2048,
                supports_tools=True,
                supports_streaming=True,
                cost_input=0.0,
                cost_output=0.0,
            ),
        }
    
    def _get_client(self):
        if self._client is None:
            try:
                from openai import AsyncOpenAI
                self._client = AsyncOpenAI(api_key=self._api_key, base_url=self._base_url)
            except ImportError:
                raise ImportError("openai package is required. Install with: pip install openai")
        return self._client