From 253b01fab057cec21f4ae6d03f8d1de29825f595 Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Mon, 27 Oct 2025 23:57:56 +0530 Subject: [PATCH] improve error handling with warnings in verbose mode --- packages/openai-sdk-python/src/supermemory_openai/wrapper.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/openai-sdk-python/src/supermemory_openai/wrapper.py b/packages/openai-sdk-python/src/supermemory_openai/wrapper.py index eef2eb53..adec9e72 100644 --- a/packages/openai-sdk-python/src/supermemory_openai/wrapper.py +++ b/packages/openai-sdk-python/src/supermemory_openai/wrapper.py @@ -1,6 +1,7 @@ """OpenAI client wrapper with Supermemory integration.""" import asyncio +import warnings from typing import Any, Dict, List, Optional, Union, overload from openai import OpenAI, AsyncOpenAI from openai.types.chat import ChatCompletion, ChatCompletionMessageParam @@ -124,6 +125,8 @@ class SupermemoryOpenAIWrapper: except Exception as error: self._log("Error saving memory", {"error": str(error)}) + if self.options.verbose: + warnings.warn(f"Failed to save memory: {error}", RuntimeWarning) async def _inject_memories(self, messages: List[ChatCompletionMessageParam]) -> List[ChatCompletionMessageParam]: """Inject relevant memories into the messages.""" @@ -165,6 +168,8 @@ class SupermemoryOpenAIWrapper: except Exception as error: self._log("Error during memory search", {"error": str(error)}) + if self.options.verbose: + warnings.warn(f"Failed to retrieve memories: {error}", RuntimeWarning) # Return original messages if memory search fails return messages