From ea9bf13d314a605f3b80c7e8ce7e3141db5438df Mon Sep 17 00:00:00 2001 From: nexxeln <95541290+nexxeln@users.noreply.github.com> Date: Tue, 11 Nov 2025 02:16:34 +0000 Subject: add openai middleware functionality for python sdk (#546) add openai middleware functionality fix critical type errors and linting issues update readme with middleware documentation --- .../src/supermemory_openai/tools.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'packages/openai-sdk-python/src/supermemory_openai/tools.py') diff --git a/packages/openai-sdk-python/src/supermemory_openai/tools.py b/packages/openai-sdk-python/src/supermemory_openai/tools.py index ec87db10..111253cd 100644 --- a/packages/openai-sdk-python/src/supermemory_openai/tools.py +++ b/packages/openai-sdk-python/src/supermemory_openai/tools.py @@ -16,6 +16,12 @@ from supermemory.types import ( ) from supermemory.types.search_execute_response import Result +from .exceptions import ( + SupermemoryConfigurationError, + SupermemoryMemoryOperationError, + SupermemoryNetworkError, +) + class SupermemoryToolsConfig(TypedDict, total=False): """Configuration for Supermemory tools. @@ -194,10 +200,15 @@ class SupermemoryTools: results=response.results, count=len(response.results), ) + except (OSError, ConnectionError) as network_error: + return MemorySearchResult( + success=False, + error=f"Network error: {network_error}", + ) except Exception as error: return MemorySearchResult( success=False, - error=str(error), + error=f"Memory search failed: {error}", ) async def add_memory(self, memory: str) -> MemoryAddResult: @@ -225,10 +236,15 @@ class SupermemoryTools: success=True, memory=response, ) + except (OSError, ConnectionError) as network_error: + return MemoryAddResult( + success=False, + error=f"Network error: {network_error}", + ) except Exception as error: return MemoryAddResult( success=False, - error=str(error), + error=f"Memory add failed: {error}", ) -- cgit v1.2.3