protobench / utils.py
vtrv.vls
Async requests
cc225d4
raw
history blame contribute delete
No virus
1.71 kB
import requests
import json
import os
from datetime import datetime
from copy import copy
def clear_chat():
return '', []
async def model_response(
content,
chat_history,
s3_session,
initialized_models,
gen_lib,
model_name,
model_params
):
print(f'{model_name} response')
chat_history.append([content])
res = gen_lib[model_name](initialized_models[model_name], chat_history, model_params)
chat_history[-1].append(res)
send_to_s3(res, f'protobench/{model_name}_{str(datetime.now()).replace(" ", "_")}.json', s3_session)
return '', chat_history
def send_to_s3(data, name, session):
session.put_object(Bucket=os.getenv('S3_BUCKET'), Key=name, Body=json.dumps(data))
# def giga_gen(content, chat_history, model, s3_session):
# chat_history.append([content])
# res = response_gigachat(chat_history,'auth_token.json')
# chat_history[-1].append(res)
# send_to_s3(res, f'protobench/giga_{str(datetime.now()).replace(" ", "_")}.json', s3_session)
# return '', chat_history
# def tiny_gen(content, chat_history, model, s3_session):
# chat_history.append([content])
# res = response_tinyllama(model, chat_history)
# chat_history[-1].append(res)
# send_to_s3(res, f'protobench/tiny_{str(datetime.now()).replace(" ", "_")}.json', s3_session)
# return '', chat_history
# def qwen_gen(content, chat_history, model, s3_session):
# chat_history.append([content])
# res = response_qwen2ins1b(model, chat_history)
# chat_history[-1].append(res)
# send_to_s3(res, f'protobench/qwen_{str(datetime.now()).replace(" ", "_")}.json', s3_session)
# return '', chat_history