Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/hello_world_portkey_adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ async def main() -> None:
final_text: List[str] = []
async for resp in llm.generate_content_async(req, stream=False):
if resp.content and getattr(resp.content, "parts", None):
for p in resp.content.parts:
if getattr(p, "text", None):
final_text.append(p.text)
for p in resp.content.parts or []:
Comment thread
narengogi marked this conversation as resolved.
text = getattr(p, "text", None)
if text:
final_text.append(text)
print("".join(final_text))


Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world_portkey_strands.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def main() -> None:
]

print(f"Streaming with model: {model_id}")
async for event in model.stream(messages=messages):
async for event in model.stream(messages=messages): # type: ignore[arg-type]
Comment thread
narengogi marked this conversation as resolved.
# Events follow the Strands stream event shape produced by our adapter.
if isinstance(event, dict) and "contentBlockDelta" in event:
delta = event["contentBlockDelta"].get("delta", {})
Expand Down
16 changes: 16 additions & 0 deletions portkey_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@
AsyncConversationsItems,
Videos,
AsyncVideos,
Skills,
AsyncSkills,
SkillsContent,
AsyncSkillsContent,
SkillsVersions,
AsyncSkillsVersions,
SkillsVersionsContent,
AsyncSkillsVersionsContent,
ChatKit,
AsyncChatKit,
ChatKitSessions,
Expand Down Expand Up @@ -347,6 +355,14 @@
"AsyncConversationsItems",
"Videos",
"AsyncVideos",
"Skills",
"AsyncSkills",
"SkillsContent",
"AsyncSkillsContent",
"SkillsVersions",
"AsyncSkillsVersions",
"SkillsVersionsContent",
"AsyncSkillsVersionsContent",
"ChatKit",
"AsyncChatKit",
"ChatKitSessions",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.3
Name: openai
Version: 2.16.0
Version: 2.30.0
Summary: The official Python library for the openai API
Project-URL: Homepage, https://github.com/openai/openai-python
Project-URL: Repository, https://github.com/openai/openai-python
Expand Down Expand Up @@ -29,7 +29,7 @@ Requires-Dist: jiter<1,>=0.10.0
Requires-Dist: pydantic<3,>=1.9.0
Requires-Dist: sniffio
Requires-Dist: tqdm>4
Requires-Dist: typing-extensions<5,>=4.11
Requires-Dist: typing-extensions<5,>=4.14
Comment thread
narengogi marked this conversation as resolved.
Provides-Extra: aiohttp
Requires-Dist: aiohttp; extra == 'aiohttp'
Requires-Dist: httpx-aiohttp>=0.1.9; extra == 'aiohttp'
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions portkey_ai/_vendor/openai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ def _reset_client() -> None: # type: ignore[reportUnusedFunction]
files as files,
images as images,
models as models,
skills as skills,
videos as videos,
batches as batches,
uploads as uploads,
Expand Down
14 changes: 12 additions & 2 deletions portkey_ai/_vendor/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
APIConnectionError,
APIResponseValidationError,
)
from ._utils._json import openapi_dumps
from ._legacy_response import LegacyAPIResponse

log: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -556,8 +557,10 @@ def _build_request(
kwargs["content"] = options.content
elif isinstance(json_data, bytes):
kwargs["content"] = json_data
else:
kwargs["json"] = json_data if is_given(json_data) else None
elif not files:
# Don't set content when JSON is sent as multipart/form-data,
# since httpx's content param overrides other body arguments
kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None
kwargs["files"] = files
else:
headers.pop("Content-Type", None)
Expand Down Expand Up @@ -784,6 +787,9 @@ def _should_retry(self, response: httpx.Response) -> bool:

return True

log.debug("Not retrying")
return False

def _idempotency_key(self) -> str:
return f"stainless-python-retry-{uuid.uuid4()}"

Expand Down Expand Up @@ -1963,6 +1969,7 @@ def make_request_options(
idempotency_key: str | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
post_parser: PostParser | NotGiven = not_given,
synthesize_event_and_data: bool | None = None,
) -> RequestOptions:
"""Create a dict of type RequestOptions without keys of NotGiven values."""
options: RequestOptions = {}
Expand All @@ -1988,6 +1995,9 @@ def make_request_options(
# internal
options["post_parser"] = post_parser # type: ignore

if synthesize_event_and_data is not None:
options["synthesize_event_and_data"] = synthesize_event_and_data

return options


Expand Down
Loading
Loading