Skip to content

Commit 62f643a

Browse files
committed
add debug output to openai compat provider
1 parent 3640afb commit 62f643a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/shelloracle/providers/openai_compat.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from collections.abc import AsyncIterator
23

34
from openai import APIError, AsyncOpenAI
@@ -26,8 +27,12 @@ async def generate(self, prompt: str) -> AsyncIterator[str]:
2627
stream=True,
2728
)
2829
async for chunk in stream:
29-
if chunk.choices[0].delta.content is not None:
30-
yield chunk.choices[0].delta.content
30+
logging.getLogger(__name__).info(chunk)
31+
try:
32+
if chunk.choices[0].delta.content is not None:
33+
yield chunk.choices[0].delta.content
34+
except:
35+
logging.getLogger(__name__).exception("no choices")
3136
except APIError as e:
32-
msg = f"Something went wrong while querying OpenAICompat: {e}"
37+
msg = f"Something went wrong while querying OpenAI: {e}"
3338
raise ProviderError(msg) from e

0 commit comments

Comments
 (0)