From 551ec37fe119d25f0be1a24ab8d07d6f12fb1872 Mon Sep 17 00:00:00 2001 From: Dani Date: Sun, 28 Jan 2024 12:46:35 -0500 Subject: [PATCH] test --- src/judini/codegpt/chat.py | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/judini/codegpt/chat.py b/src/judini/codegpt/chat.py index 936b299..2b2f624 100644 --- a/src/judini/codegpt/chat.py +++ b/src/judini/codegpt/chat.py @@ -20,35 +20,35 @@ def create(self, agent_id, messages, stream=False): "messages": messages }) - conn = http.client.HTTPSConnection("api-beta.codegpt.co") - url = "/api/v1/chat/completions" - - conn.request("POST", url, body=payload, headers=headers) - res = conn.getresponse() - try: - data = res.read() - except Exception as e: - print(f"An error occurred: {e.__class__.__name__}") - print(f"Error details: {str(e)}") - - content_data = "" - if stream is False: - data.decode("utf-8").replace('\n','').split('data: ')[1:] - for jd_str in data: - if jd_str: - try: - # data: {} - json_data = json.loads(jd_str) - for item in json_data['choices']: - content_data += item['delta']['content'] - except: - # data: [DONE] - pass - - return content_data - else: - try: - return data.decode("utf-8").replace('\n','').split('data: ')[1:] - except Exception as e: - print(f"An error occurred: {e.__class__.__name__}") - print(f"Error details: {str(e)}") + # conn = http.client.HTTPSConnection("api-beta.codegpt.co") + # url = "/api/v1/chat/completions" + + # conn.request("POST", url, body=payload, headers=headers) + # res = conn.getresponse() + # try: + # data = res.read() + # except Exception as e: + # print(f"An error occurred: {e.__class__.__name__}") + # print(f"Error details: {str(e)}") + + # content_data = "" + # if stream is False: + # data.decode("utf-8").replace('\n','').split('data: ')[1:] + # for jd_str in data: + # if jd_str: + # try: + # # data: {} + # json_data = json.loads(jd_str) + # for item in json_data['choices']: + # content_data += item['delta']['content'] + # except: + # # data: [DONE] + # pass + + # return content_data + # else: + # try: + # return data.decode("utf-8").replace('\n','').split('data: ')[1:] + # except Exception as e: + # print(f"An error occurred: {e.__class__.__name__}") + # print(f"Error details: {str(e)}")