11from typing import Union
22import os
3- from .audio import Audio
4- from .vision import Vision
3+ from .audio import Audio , AsyncAudio
4+ from .vision import Vision , AsyncVision
55from .search import Search
6- from .prediction import Prediction
7- from .sql import SQL
8- from .store import KV , Store
9- from .translate import Translate
10- from .web import Web
11- from .sentiment import Sentiment
12- from .validate import Validate
13- from .summary import Summary
14- from .geo import Geo
15- from .prompt_engine import PromptEngine
6+ from .prediction import Prediction , AsyncPrediction
7+ from .sql import SQL , AsyncSQL
8+ from .store import Store , AsyncStore
9+ from .translate import Translate , AsyncTranslate
10+ from .web import Web , AsyncWeb
11+ from .sentiment import Sentiment , AsyncSentiment
12+ from .validate import Validate , AsyncValidate
13+ from .summary import Summary , AsyncSummary
14+ from .geo import Geo , AsyncGeo
15+ from .prompt_engine import PromptEngine , AsyncPromptEngine
1616from .exceptions import JigsawStackError
1717
18- # from .version import get_version
19-
2018
2119class JigsawStack :
2220 audio : Audio
2321 vision : Vision
24- prediction : Prediction
25- text_to_sql : SQL
2622 file : Store
27- kv : KV
28- translate : Translate
2923 web : Web
30- sentiment : Sentiment
31- validate : Validate
32- summary : Summary
3324 search : Search
3425 geo : Geo
3526 prompt_engine : PromptEngine
@@ -104,11 +95,6 @@ def __init__(
10495 api_url = api_url ,
10596 disable_request_logging = disable_request_logging ,
10697 )
107- self .kv = KV (
108- api_key = api_key ,
109- api_url = api_url ,
110- disable_request_logging = disable_request_logging ,
111- )
11298 self .translate = Translate (
11399 api_key = api_key ,
114100 api_url = api_url ,
@@ -126,5 +112,110 @@ def __init__(
126112 )
127113
128114
115+ class AsyncJigsawStack :
116+ geo : AsyncGeo
117+ validate : AsyncValidate
118+ web : AsyncWeb
119+ audio : AsyncAudio
120+ vision : AsyncVision
121+ store : AsyncStore
122+ prompt_engine : AsyncPromptEngine
123+ api_key : str
124+ api_url : str
125+ disable_request_logging : bool
126+
127+ def __init__ (
128+ self ,
129+ api_key : Union [str , None ] = None ,
130+ api_url : Union [str , None ] = None ,
131+ disable_request_logging : Union [bool , None ] = None ,
132+ ) -> None :
133+ if api_key is None :
134+ api_key = os .environ .get ("JIGSAWSTACK_API_KEY" )
135+
136+ if api_key is None :
137+ raise ValueError (
138+ "The api_key client option must be set either by passing api_key to the client or by setting the JIGSAWSTACK_API_KEY environment variable"
139+ )
140+
141+ if api_url is None :
142+ api_url = os .environ .get ("JIGSAWSTACK_API_URL" )
143+ if api_url is None :
144+ api_url = f"https://api.jigsawstack.com/v1"
145+
146+ self .api_key = api_key
147+ self .api_url = api_url
148+
149+ self .web = AsyncWeb (
150+ api_key = api_key ,
151+ api_url = api_url ,
152+ disable_request_logging = disable_request_logging ,
153+ )
154+
155+ self .geo = AsyncGeo (
156+ api_key = api_key ,
157+ api_url = api_url ,
158+ disable_request_logging = disable_request_logging ,
159+ )
160+
161+ self .validate = AsyncValidate (
162+ api_key = api_key ,
163+ api_url = api_url ,
164+ disable_request_logging = disable_request_logging ,
165+ )
166+ self .audio = AsyncAudio (
167+ api_key = api_key ,
168+ api_url = api_url ,
169+ disable_request_logging = disable_request_logging ,
170+ )
171+
172+ self .vision = AsyncVision (
173+ api_key = api_key ,
174+ api_url = api_url ,
175+ disable_request_logging = disable_request_logging ,
176+ )
177+
178+ self .store = AsyncStore (
179+ api_key = api_key ,
180+ api_url = api_url ,
181+ disable_request_logging = disable_request_logging ,
182+ )
183+
184+ self .summary = AsyncSummary (
185+ api_key = api_key ,
186+ api_url = api_url ,
187+ disable_request_logging = disable_request_logging ,
188+ ).summarize
189+
190+ self .prediction = AsyncPrediction (
191+ api_key = api_key ,
192+ api_url = api_url ,
193+ disable_request_logging = disable_request_logging ,
194+ ).predict
195+ self .text_to_sql = AsyncSQL (
196+ api_key = api_key ,
197+ api_url = api_url ,
198+ disable_request_logging = disable_request_logging ,
199+ ).text_to_sql
200+
201+ self .sentiment = AsyncSentiment (
202+ api_key = api_key ,
203+ api_url = api_url ,
204+ disable_request_logging = disable_request_logging ,
205+ ).analyze
206+
207+ self .translate = AsyncTranslate (
208+ api_key = api_key ,
209+ api_url = api_url ,
210+ disable_request_logging = disable_request_logging ,
211+ ).translate
212+
213+ self .prompt_engine = AsyncPromptEngine (
214+ api_key = api_key ,
215+ api_url = api_url ,
216+ disable_request_logging = disable_request_logging ,
217+ )
218+
219+
129220# Create a global instance of the Web class
130- __all__ = ["JigsawStack" , "Search" , "JigsawStackError" ]
221+ __all__ = ["JigsawStack" , "Search" , "JigsawStackError" , "AsyncJigsawStack" ]
0 commit comments