chatgpt send request and fix logic for max tokens

Lu Yao Chen 2 years ago
parent ab5ac691eb
commit d78a7d2fad
No known key found for this signature in database
GPG Key ID: 0D8EDAEEE816135F

@ -1018,7 +1018,7 @@ class Model:
# Validate that all the parameters are in a good state before we send the request
if not max_tokens_override:
if model:
if model and model not in Models.GPT4_MODELS and model not in Models.CHATGPT_MODELS:
max_tokens_override = Models.get_max_tokens(model) - tokens
print(f"The prompt about to be sent is {prompt}")

@ -16,6 +16,16 @@ async def test_send_req():
model = Model(usage_service)
prompt = 'how many hours are in a day?'
tokens = len(GPT2TokenizerFast.from_pretrained("gpt2")(prompt)["input_ids"])
# tokens = 60
res = await model.send_request(prompt, tokens)
assert '24' in res['choices'][0]['text']
# ChatGPT version
@pytest.mark.asyncio
async def test_send_req_gpt():
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-3.5-turbo")
assert '24' in res['choices'][0]['message']['content']
Loading…
Cancel
Save