From d85cf50c113e69c1a54eeb0735e5746a1d6ea909 Mon Sep 17 00:00:00 2001 From: Lu Yao Chen Date: Thu, 23 Mar 2023 15:08:52 -0700 Subject: [PATCH] fixes --- gpt3discord.py | 2 +- requirements.txt | 4 +++- tests/test_requests.py | 30 +++++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/gpt3discord.py b/gpt3discord.py index cd8b45b..fc4fcc0 100644 --- a/gpt3discord.py +++ b/gpt3discord.py @@ -33,7 +33,7 @@ from services.environment_service import EnvService from models.openai_model import Model -__version__ = "11.1.1" +__version__ = "11.1.5" PID_FILE = Path("bot.pid") diff --git a/requirements.txt b/requirements.txt index 754cf34..9980544 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,4 +24,6 @@ openai-whisper unidecode==1.3.6 tqdm==4.64.1 docx2txt==0.8 -pytest-asyncio==0.21.0 \ No newline at end of file +pytest-asyncio==0.21.0 +aiohttp~=3.8.4 +pytest~=7.2.2 \ No newline at end of file diff --git a/tests/test_requests.py b/tests/test_requests.py index 14ef128..aec41fd 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -1,14 +1,13 @@ from pathlib import Path import pytest -from models.openai_model import Models, Model +from models.openai_model import Model from transformers import GPT2TokenizerFast -import asyncio from services.usage_service import UsageService -import os -# Non-ChatGPT + +# Non-ChatGPT -> TODO: make generic test and loop through text models @pytest.mark.asyncio async def test_send_req(): @@ -28,4 +27,25 @@ async def test_send_req_gpt(): model = Model(usage_service) prompt = 'how many hours are in a day?' res = await model.send_request(prompt, None, is_chatgpt_request=True, model="gpt-3.5-turbo") - assert '24' in res['choices'][0]['message']['content'] \ No newline at end of file + assert '24' in res['choices'][0]['message']['content'] + + +# GPT4 version +@pytest.mark.asyncio +async def test_send_req_gpt4(): + usage_service = UsageService(Path("../tests")) + model = Model(usage_service) + prompt = 'how many hours are in a day?' + res = await model.send_request(prompt, None, is_chatgpt_request=True, model="gpt-4") + assert '24' in res['choices'][0]['message']['content'] + + +# Edit request -> currently broken due to endpoint +# @pytest.mark.asyncio +# async def test_send_edit_req(): +# usage_service = UsageService(Path("../tests")) +# model = Model(usage_service) +# text = 'how many hours are in a day?' +# res = await model.send_edit_request(text, codex=True) +# assert '24' in res['choices'][0]['text'] +