File tree 5 files changed +23
-4
lines changed
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 1
1
"""
2
2
𐃏 Substrate Python SDK
3
3
4
- 20240617.20240727
4
+ 20240617.20240802
5
5
"""
6
6
7
7
from .nodes import (
51
51
)
52
52
from .core .sb import sb
53
53
from ._version import __version__
54
- from .substrate import Substrate , SubstrateResponse
54
+ from .substrate import Secrets , Substrate , SubstrateResponse
55
55
from .run_python import RunPython
56
56
57
57
__all__ = [
58
58
"__version__" ,
59
+ "Secrets" ,
59
60
"SubstrateResponse" ,
60
61
"sb" ,
61
62
"Substrate" ,
Original file line number Diff line number Diff line change 1
1
"""
2
2
CORE ꩜ SUBSTRATE
3
3
"""
4
- from typing import Any , Union
4
+ from re import template
5
+ from typing import Any , Dict , Union
5
6
6
7
from .client .future import Future
7
8
from .future_directive import (
Original file line number Diff line number Diff line change 6
6
7
7
import warnings
8
8
9
+ from .substrate import SubstrateResponse
9
10
from .core .corenode import CoreNode
10
11
11
12
# filter pydantic v2 deprecation warnings
17
18
CLIPOut ,
18
19
JinaV2Out ,
19
20
EmbedTextOut ,
21
+ RunPythonOut ,
20
22
EmbedImageOut ,
21
23
EraseImageOut ,
22
24
ComputeJSONOut ,
57
59
StableDiffusionXLControlNetOut ,
58
60
)
59
61
from typing import Any , Dict , List , Optional
62
+ from dataclasses import dataclass
60
63
from typing_extensions import Literal
61
64
62
65
from .future_dataclass_models import (
65
68
FutureCLIPOut ,
66
69
FutureJinaV2Out ,
67
70
FutureEmbedTextOut ,
71
+ FutureRunPythonOut ,
68
72
FutureEmbedImageOut ,
69
73
FutureEraseImageOut ,
70
74
FutureComputeJSONOut ,
Original file line number Diff line number Diff line change 1
1
import json
2
2
import zlib
3
3
import base64
4
+ import dataclasses
4
5
from typing import Any , Dict , Optional
5
6
6
7
from substrate .streaming import SubstrateStreamingResponse
11
12
from .substrate_response import SubstrateResponse
12
13
13
14
15
+ @dataclasses .dataclass
16
+ class Secrets :
17
+ openai : Optional [str ] = None
18
+ anthropic : Optional [str ] = None
19
+
20
+
14
21
class Substrate :
15
22
"""
16
23
Substrate client.
@@ -21,6 +28,7 @@ def __init__(
21
28
api_key : str ,
22
29
base_url : str = "https://api.substrate.run" ,
23
30
timeout : float = 60 * 5.0 ,
31
+ secrets : Optional [Secrets ] = None ,
24
32
additional_headers : Optional [Dict [str , Any ]] = None ,
25
33
):
26
34
"""
@@ -29,6 +37,11 @@ def __init__(
29
37
if additional_headers is None :
30
38
additional_headers = {}
31
39
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
32
45
self ._client = APIClient (
33
46
api_key = api_key ,
34
47
base_url = base_url ,
You can’t perform that action at this time.
0 commit comments