Skip to content

Commit

Permalink
check status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
gptlang committed Feb 1, 2024
1 parent f8823af commit f3f14de
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rplugin/python3/copilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def ask(self, system_prompt: str, prompt: str, code: str, language: str = ""):
response = self.session.post(
url, headers=self._headers(), json=data, stream=True
)
if response.status_code != 200:
raise Exception(f"Error fetching response: {response}")
for line in response.iter_lines():
line = line.decode("utf-8").replace("data: ", "").strip()
if line.startswith("[DONE]"):
Expand Down

0 comments on commit f3f14de

Please sign in to comment.