Skip to content

Commit b2a110d

Browse files
committed
update embedding
1 parent d91415d commit b2a110d

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

jigsawstack/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .summary import Summary, AsyncSummary
1414
from .geo import Geo, AsyncGeo
1515
from .prompt_engine import PromptEngine, AsyncPromptEngine
16+
from .embedding import Embedding, AsyncEmbedding
1617
from .exceptions import JigsawStackError
1718

1819

@@ -110,6 +111,11 @@ def __init__(
110111
api_url=api_url,
111112
disable_request_logging=disable_request_logging,
112113
)
114+
self.embedding = Embedding(
115+
api_key=api_key,
116+
api_url=api_url,
117+
disable_request_logging=disable_request_logging,
118+
).execute
113119

114120

115121
class AsyncJigsawStack:
@@ -215,6 +221,11 @@ def __init__(
215221
api_url=api_url,
216222
disable_request_logging=disable_request_logging,
217223
)
224+
self.embedding = AsyncEmbedding(
225+
api_key=api_key,
226+
api_url=api_url,
227+
disable_request_logging=disable_request_logging,
228+
).execute
218229

219230

220231
# Create a global instance of the Web class
Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,18 @@
77

88

99
class EmbeddingParams(TypedDict):
10-
text: Union[str, List[str]]
11-
"""
12-
The text to summarize.
13-
"""
14-
15-
type: NotRequired[Literal["text", "points"]]
16-
17-
"""
18-
The summary result type. Supported values are: text, points
19-
"""
10+
text: NotRequired[str]
11+
file_content: NotRequired[Any]
12+
type: Literal["text", "text-other", "image", "audio", "pdf"]
2013
url: NotRequired[str]
2114
file_store_key: NotRequired[str]
22-
max_points: NotRequired[int]
23-
max_characters: NotRequired[int]
15+
token_overflow_mode: NotRequired[Literal["truncate", "chunk", "error"]] = "chunk"
2416

2517

2618
class EmbeddingResponse(TypedDict):
2719
success: bool
28-
"""
29-
Indicates whether the translation was successful.
30-
"""
31-
summary: str
32-
"""
33-
The summarized text.
34-
"""
20+
embeddings: List[List[float]]
21+
chunks: List[str]
3522

3623

3724
class Embedding(ClientConfig):
@@ -51,6 +38,16 @@ def __init__(
5138
disable_request_logging=disable_request_logging,
5239
)
5340

41+
def execute(self, params: EmbeddingParams) -> EmbeddingResponse:
42+
path = "/embedding"
43+
resp = Request(
44+
config=self.config,
45+
path=path,
46+
params=cast(Dict[Any, Any], params),
47+
verb="post",
48+
).perform_with_content()
49+
return resp
50+
5451

5552
class AsyncEmbedding(ClientConfig):
5653

@@ -70,7 +67,7 @@ def __init__(
7067
)
7168

7269
async def execute(self, params: EmbeddingParams) -> EmbeddingResponse:
73-
path = "/ai/embedding"
70+
path = "/embedding"
7471
resp = await AsyncRequest(
7572
config=self.config,
7673
path=path,

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.24",
9+
version="0.1.25",
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)