Skip to content

Commit a3bdaf5

Browse files
committed
chore:clean up
1 parent 3895ac6 commit a3bdaf5

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

jigsawstack/prompt_engine.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ def create(self, params: PromptEngineCreateParams) -> PromptEngineCreateResponse
5959
return resp
6060

6161
def get(self, id:str) -> PromptEngineGetResponse:
62-
path = f"/prompt_engine/${id}"
62+
path = f"/prompt_engine/{id}"
6363
resp = Request(
6464
api_key=self.api_key,
6565
api_url=self.api_url,
66-
path=path,params=cast(Dict[Any, Any], params={}),verb="get").perform_with_content()
66+
path=path,params={},verb="get").perform_with_content()
6767
return resp
6868

6969
def list(self, params:PromptEngineListParams) -> PromptEngineListResponse:
@@ -73,26 +73,30 @@ def list(self, params:PromptEngineListParams) -> PromptEngineListResponse:
7373

7474
if params.get('page') is None:
7575
params['page'] = 1
76+
7677

77-
path = f"/prompt_engine?limit={params["limit"]}&page={params["page"]}"
78+
limit = params.get('limit')
79+
page = params.get('page')
80+
81+
path = f"/prompt_engine?limit={limit}&page={page}"
7882
resp = Request(
7983
api_key=self.api_key,
8084
api_url=self.api_url,
81-
path=path,params=cast(Dict[Any, Any], params={}),verb="get").perform_with_content()
85+
path=path,params={},verb="get").perform_with_content()
8286
return resp
8387

8488
def delete(self, id:str) -> PromptEngineDeleteResponse:
85-
path = f"/prompt_engine/${id}"
89+
path = f"/prompt_engine/{id}"
8690
resp = Request(
8791
api_key=self.api_key,
8892
api_url=self.api_url,
89-
path=path,params=cast(Dict[Any, Any], params={}),verb="DELETE").perform_with_content()
93+
path=path,params={},verb="DELETE").perform_with_content()
9094
return resp
9195

9296
def run(self, id:str, params:PromptEngineRunParams) -> PromptEngineRunResponse:
93-
path = f"/prompt_engine/${id}"
97+
path = f"/prompt_engine/{id}"
9498
resp = Request(
9599
api_key=self.api_key,
96100
api_url=self.api_url,
97-
path=path,params=cast(Dict[Any, Any], params),verb="get").perform_with_content()
101+
path=path,params=cast(Dict[Any, Any], params),verb="post").perform_with_content()
98102
return resp

jigsawstack/request.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def perform(self) -> Union[T, None]:
3737
"""
3838
resp = self.make_request(url=f"{self.api_url}{self.path}")
3939

40+
41+
url= f"{self.api_url}{self.path}"
42+
43+
print(url)
44+
45+
46+
4047
# delete calls do not return a body
4148
if resp.text == "" and resp.status_code == 200:
4249
return None

setup.py

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

88
setup(
99
name="jigsawstack",
10-
version="0.1.1",
10+
version="0.1.2",
1111
description="JigsawStack Python SDK",
1212
long_description=open("README.md", encoding="utf8").read(),
1313
long_description_content_type="text/markdown",

tests/test_prompt_engine.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from unittest.mock import MagicMock
2+
import unittest
3+
from jigsawstack.exceptions import JigsawStackError
4+
import jigsawstack
5+
import pytest
6+
# flake8: noq
7+
8+
jigsaw = jigsawstack.JigsawStack()
9+
10+
11+
class TestPromptEngine(unittest.TestCase):
12+
13+
def test_get_prompt_engine_response_success(self) -> None:
14+
try:
15+
result = jigsaw.prompt_engine.get("b08921b8-0b30-409e-8257-06fa1620c7e6")
16+
assert result["success"] == True
17+
except JigsawStackError as e:
18+
assert e.message == "Failed to parse API response. Please try again."

0 commit comments

Comments
 (0)