Skip to content

Commit 6724f01

Browse files
committed
🐛 FIX: Types
1 parent bd50ec1 commit 6724f01

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

langbase/request.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ def make_request(
101101
try:
102102
# If files are provided, don't send JSON body
103103
if files:
104+
# Remove Content-Type header for file uploads (requests will set it automatically)
105+
filtered_headers = {
106+
k: v for k, v in headers.items() if k != "Content-Type"
107+
}
104108
response = requests.request(
105109
method=method,
106110
url=url,
107-
headers={k: v for k, v in headers.items() if k != "Content-Type"},
111+
headers=filtered_headers,
108112
files=files,
109113
stream=stream,
110114
)
@@ -275,25 +279,28 @@ def send(
275279
thread_id = response.headers.get("lb-thread-id")
276280

277281
if not body:
282+
raw_response = body.get("raw_response", False) if body else False
278283
return self.handle_run_response(
279284
response,
280285
thread_id=None,
281-
raw_response=body.get("raw_response", False) if body else False,
286+
raw_response=raw_response,
282287
endpoint=endpoint,
283288
)
284289

285290
if body.get("stream") and "run" in url:
291+
raw_response = body.get("raw_response", False)
286292
return self.handle_run_response_stream(
287-
response, raw_response=body.get("raw_response", False)
293+
response, raw_response=raw_response
288294
)
289295

290296
if body.get("stream"):
291297
return self.handle_stream_response(response)
292298

299+
raw_response = body.get("raw_response", False)
293300
return self.handle_run_response(
294301
response,
295302
thread_id=thread_id,
296-
raw_response=body.get("raw_response", False),
303+
raw_response=raw_response,
297304
endpoint=endpoint,
298305
)
299306
# For non-generation endpoints, just return the JSON response

langbase/types.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,11 @@ class ToolChoice(TypedDict):
7979
function: Dict[str, str]
8080

8181

82-
# Message types
83-
class MessageContentItem(TypedDict, total=False):
84-
"""Content item for a message with multiple content parts."""
85-
86-
type: str
87-
text: Optional[str]
88-
image_url: Optional[Dict[str, str]]
89-
cache_control: Optional[Dict[str, str]]
90-
91-
9282
class Message(TypedDict, total=False):
9383
"""Basic message structure."""
9484

9585
role: Role
96-
content: Optional[Union[str, List[MessageContentItem]]]
86+
content: string | NULL
9787
name: Optional[str]
9888
tool_call_id: Optional[str]
9989
tool_calls: Optional[List[ToolCall]]
@@ -783,6 +773,3 @@ class AgentRunOptionsStreamT(TypedDict):
783773

784774
# Agent response type (reuses RunResponse)
785775
AgentRunResponse = RunResponse
786-
787-
788-
# Workflow types - moved to workflow.py for better type support with generics

0 commit comments

Comments
 (0)