File tree Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1- 20240617.20240727
1+ 20240617.20240802
Original file line number Diff line number Diff line change 11"""
22𐃏 Substrate Python SDK
33
4- 20240617.20240727
4+ 20240617.20240802
55"""
66
77from .nodes import (
5151)
5252from .core .sb import sb
5353from ._version import __version__
54- from .substrate import Substrate , SubstrateResponse
54+ from .substrate import Secrets , Substrate , SubstrateResponse
5555from .run_python import RunPython
5656
5757__all__ = [
5858 "__version__" ,
59+ "Secrets" ,
5960 "SubstrateResponse" ,
6061 "sb" ,
6162 "Substrate" ,
Original file line number Diff line number Diff line change 11"""
22CORE ꩜ SUBSTRATE
33"""
4- from typing import Any , Union
4+ from re import template
5+ from typing import Any , Dict , Union
56
67from .client .future import Future
78from .future_directive import (
Original file line number Diff line number Diff line change 66
77import warnings
88
9+ from .substrate import SubstrateResponse
910from .core .corenode import CoreNode
1011
1112# filter pydantic v2 deprecation warnings
1718 CLIPOut ,
1819 JinaV2Out ,
1920 EmbedTextOut ,
21+ RunPythonOut ,
2022 EmbedImageOut ,
2123 EraseImageOut ,
2224 ComputeJSONOut ,
5759 StableDiffusionXLControlNetOut ,
5860 )
5961from typing import Any , Dict , List , Optional
62+ from dataclasses import dataclass
6063from typing_extensions import Literal
6164
6265from .future_dataclass_models import (
6568 FutureCLIPOut ,
6669 FutureJinaV2Out ,
6770 FutureEmbedTextOut ,
71+ FutureRunPythonOut ,
6872 FutureEmbedImageOut ,
6973 FutureEraseImageOut ,
7074 FutureComputeJSONOut ,
Original file line number Diff line number Diff line change 11import json
22import zlib
33import base64
4+ import dataclasses
45from typing import Any , Dict , Optional
56
67from substrate .streaming import SubstrateStreamingResponse
1112from .substrate_response import SubstrateResponse
1213
1314
15+ @dataclasses .dataclass
16+ class Secrets :
17+ openai : Optional [str ] = None
18+ anthropic : Optional [str ] = None
19+
20+
1421class Substrate :
1522 """
1623 Substrate client.
@@ -21,6 +28,7 @@ def __init__(
2128 api_key : str ,
2229 base_url : str = "https://api.substrate.run" ,
2330 timeout : float = 60 * 5.0 ,
31+ secrets : Optional [Secrets ] = None ,
2432 additional_headers : Optional [Dict [str , Any ]] = None ,
2533 ):
2634 """
@@ -29,6 +37,11 @@ def __init__(
2937 if additional_headers is None :
3038 additional_headers = {}
3139 self .api_key = api_key
40+ if secrets is not None :
41+ if secrets .openai is not None :
42+ additional_headers ["x-substrate-openai-api-key" ] = secrets .openai
43+ if secrets .anthropic is not None :
44+ additional_headers ["x-substrate-anthropic-api-key" ] = secrets .anthropic
3245 self ._client = APIClient (
3346 api_key = api_key ,
3447 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments