Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion devchat/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def iterate_response(self) -> Iterator[str]:
if self._chat.config.stream:
created_time = int(time.time())
config_params = self._chat.config.dict(exclude_unset=True)
for chunk in self._chat.stream_response(self._prompt):
stream_responses = self._chat.stream_response(self._prompt)
if not stream_responses:
raise RuntimeError("No response returned from the chat API")
for chunk in stream_responses:
try:
if hasattr(chunk, "dict"):
chunk = chunk.dict()
Expand Down
3 changes: 2 additions & 1 deletion devchat/openai/http_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def stream_response(connection: http.client.HTTPSConnection, data, headers):
response = connection.getresponse()

if response.status != 200:
print(f"Error: {response.status} - {response.reason}")
print(f"Error: {response.status} - {response.reason} {response.read()}",
end="\n\n", file=sys.stderr)
return None
return LineReader(response=response)

Expand Down