Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Include response in exception
Browse files Browse the repository at this point in the history
  • Loading branch information
terry3041 committed Dec 7, 2022
1 parent b188f88 commit b3fbf79
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyChatGPT"
version = "0.0.7"
version = "0.0.8"
authors = [
{ name="terry3041", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion src/pyChatGPT/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from pyChatGPT import ChatGPT
import os


def clear_screen():
Expand Down
8 changes: 3 additions & 5 deletions src/pyChatGPT/pyChatGPT.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests
import uuid
import json
import requests


class ChatGPT:
Expand Down Expand Up @@ -38,8 +38,7 @@ def refresh_auth(self) -> None:
proxies=self.proxies,
)
if resp.status_code != 200:
print(resp.text)
raise ValueError(f'Status code {resp.status_code}')
raise ValueError(f'Status code {resp.status_code}: {resp.text}')

data = resp.json()
if not data:
Expand Down Expand Up @@ -85,8 +84,7 @@ def send_message(self, message: str) -> dict:
stream=True,
)
if resp.status_code != 200:
print(resp.text)
raise ValueError(f'Status code {resp.status_code}')
raise ValueError(f'Status code {resp.status_code}: {resp.text}')

data = list(resp.iter_lines())[-4].decode('utf-8').lstrip('data: ')
data = json.loads(data)
Expand Down

0 comments on commit b3fbf79

Please sign in to comment.