Skip to content

Commit e97f2d3

Browse files
Update CURSOR_MEMORY.md with additional tracing solution example
Co-authored-by: vinicius <[email protected]>
1 parent f1fe7ad commit e97f2d3

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

CURSOR_MEMORY.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
2. Alternative: Use ONLY `@trace_async()` decorator (but lose OpenAI-specific metrics)
2929
3. **NEVER**: Mix decorators with client tracing - this always causes duplicates
3030

31-
**Confirmed Working Solution**:
31+
**Confirmed Working Solutions**:
32+
33+
**Option 1 - No Function Tracing** (simplest):
3234
```python
3335
class say_hi:
3436
def __init__(self):
@@ -41,6 +43,21 @@ class say_hi:
4143
# ... rest of streaming logic
4244
```
4345

46+
**Option 2 - With Function Tracing** (recommended):
47+
```python
48+
class say_hi:
49+
def __init__(self):
50+
self.openai_client = trace_async_openai(AsyncOpenAI())
51+
52+
@trace_async() # ✅ Works when function returns string
53+
async def hi(self, cur_str: str) -> str: # Return complete response
54+
response = await self.openai_client.chat.completions.create(...)
55+
complete_answer = ""
56+
async for chunk in response:
57+
complete_answer += chunk.choices[0].delta.content or ""
58+
return complete_answer # ✅ Return instead of yield
59+
```
60+
4461
## Project Structure Insights
4562

4663
### Tracing Architecture

0 commit comments

Comments
 (0)