Skip to content

Commit 306eeb5

Browse files
fix: multipartform request.
1 parent d61fe05 commit 306eeb5

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

jigsawstack/embedding.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from importlib.metadata import files
12
from typing import Any, Dict, List, Literal, Union, cast, overload
23

34
from typing_extensions import NotRequired, TypedDict
@@ -55,6 +56,7 @@ def execute(
5556
options: EmbeddingParams = None,
5657
) -> EmbeddingResponse:
5758
path = "/embedding"
59+
options = options or {}
5860
if isinstance(blob, dict):
5961
resp = Request(
6062
config=self.config,
@@ -64,17 +66,14 @@ def execute(
6466
).perform_with_content()
6567
return resp
6668

67-
options = options or {}
68-
path = build_path(base_path=path, params=options)
69-
content_type = options.get("content_type", "application/octet-stream")
70-
_headers = {"Content-Type": content_type}
71-
69+
70+
files = {"file": blob}
7271
resp = Request(
7372
config=self.config,
7473
path=path,
7574
params=options,
7675
data=blob,
77-
headers=_headers,
76+
files=files,
7877
verb="post",
7978
).perform_with_content()
8079
return resp
@@ -107,6 +106,7 @@ async def execute(
107106
options: EmbeddingParams = None,
108107
) -> EmbeddingResponse:
109108
path = "/embedding"
109+
options = options or {}
110110
if isinstance(blob, dict):
111111
resp = await AsyncRequest(
112112
config=self.config,
@@ -116,17 +116,13 @@ async def execute(
116116
).perform_with_content()
117117
return resp
118118

119-
options = options or {}
120-
path = build_path(base_path=path, params=options)
121-
content_type = options.get("content_type", "application/octet-stream")
122-
_headers = {"Content-Type": content_type}
123-
119+
files = {"file": blob}
124120
resp = await AsyncRequest(
125121
config=self.config,
126122
path=path,
127123
params=options,
128124
data=blob,
129-
headers=_headers,
125+
files=files,
130126
verb="post",
131127
).perform_with_content()
132128
return resp

jigsawstack/embedding_v2.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def execute(
5353
options: EmbeddingV2Params = None,
5454
) -> EmbeddingV2Response:
5555
path = "/embedding"
56+
options = options or {}
5657
if isinstance(blob, dict):
5758
resp = Request(
5859
config=self.config,
@@ -62,17 +63,13 @@ def execute(
6263
).perform_with_content()
6364
return resp
6465

65-
options = options or {}
66-
path = build_path(base_path=path, params=options)
67-
content_type = options.get("content_type", "application/octet-stream")
68-
_headers = {"Content-Type": content_type}
69-
66+
files = {"file": blob}
7067
resp = Request(
7168
config=self.config,
7269
path=path,
7370
params=options,
7471
data=blob,
75-
headers=_headers,
72+
files=files,
7673
verb="post",
7774
).perform_with_content()
7875
return resp
@@ -107,6 +104,7 @@ async def execute(
107104
options: EmbeddingV2Params = None,
108105
) -> EmbeddingV2Response:
109106
path = "/embedding"
107+
options = options or {}
110108
if isinstance(blob, dict):
111109
resp = await AsyncRequest(
112110
config=self.config,
@@ -116,17 +114,13 @@ async def execute(
116114
).perform_with_content()
117115
return resp
118116

119-
options = options or {}
120-
path = build_path(base_path=path, params=options)
121-
content_type = options.get("content_type", "application/octet-stream")
122-
_headers = {"Content-Type": content_type}
123-
117+
files = {"file": blob}
124118
resp = await AsyncRequest(
125119
config=self.config,
126120
path=path,
127121
params=options,
128122
data=blob,
129-
headers=_headers,
123+
files=files,
130124
verb="post",
131125
).perform_with_content()
132126
return resp

0 commit comments

Comments
 (0)