Skip to content

Commit ec238a7

Browse files
committed
update prompt engine
1 parent 020f2cf commit ec238a7

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

jigsawstack/prompt_engine.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class PromptEngineRunParams(TypedDict):
1616
inputs: NotRequired[List[object]]
1717
return_prompt: Union[str, List[object], Dict[str, str]]
1818
input_values: NotRequired[Dict[str, str]]
19+
stream: Union[bool, None] = False
20+
use_internet: Union[bool, None] = False
1921

2022

2123
class PromptEngineExecuteParams(TypedDict):
@@ -31,9 +33,10 @@ class PromptEngineRunResponse(TypedDict):
3133

3234
class PromptEngineCreateParams(TypedDict):
3335
prompt: str
34-
# grok_key: NotRequired[str]
3536
inputs: NotRequired[List[object]]
3637
return_prompt: Union[str, List[object], Dict[str, str]]
38+
use_internet: Union[bool, None] = False
39+
optimize_prompt: Union[bool, None] = False
3740

3841

3942
class PromptEngineCreateResponse(TypedDict):
@@ -128,8 +131,18 @@ def delete(self, id: str) -> PromptEngineDeleteResponse:
128131

129132
def run_prompt_direct(
130133
self, params: PromptEngineRunParams
131-
) -> PromptEngineRunResponse:
134+
) -> Union[PromptEngineRunResponse, Generator[Any, None, None]]:
132135
path = "/prompt_engine/run"
136+
stream = params.get("stream")
137+
if stream:
138+
resp = Request(
139+
config=self.config,
140+
path=path,
141+
params=cast(Dict[Any, Any], params),
142+
verb="post",
143+
).perform_with_content_streaming()
144+
return resp
145+
133146
resp = Request(
134147
config=self.config,
135148
path=path,

jigsawstack/request.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,6 @@ def perform_streaming(self) -> Generator[Union[T, str], None, None]:
172172
if resp.text == "":
173173
return None
174174

175-
# this is a safety net, if we get here it means the JigsawStack API is having issues
176-
# and most likely the gateway is returning htmls
177-
if "application/json" not in resp.headers["content-type"]:
178-
raise_for_code_and_type(
179-
code=500,
180-
message="Failed to parse JigsawStack API response. Please try again.",
181-
)
182-
183175
if resp.status_code != 200:
184176
error = resp.json()
185177
raise_for_code_and_type(
@@ -209,7 +201,7 @@ def chunk_generator():
209201

210202
return chunk_generator()
211203

212-
def perform_with_content_streaming(self) -> T:
204+
def perform_with_content_streaming(self) -> Generator[Union[T, str], None, None]:
213205
"""
214206
Perform an HTTP request and return the response content as a streaming response.
215207

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="jigsawstack",
9-
version="0.1.17",
9+
version="0.1.18",
1010
description="JigsawStack Python SDK",
1111
long_description=open("README.md", encoding="utf8").read(),
1212
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)