Spaces:
Sleeping
Sleeping
File size: 1,711 Bytes
623a39b 4fa4c7b cc225d4 4fa4c7b b49edc5 4fa4c7b 014ba5e 4fa4c7b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
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
|