Spaces:
Sleeping
Sleeping
Update app.py
Browse files45 unmodified lines4647484950515253545548 unmodified lines1041051061071081091101111121131141 unmodified line11611711811912012112212312412512612712812 unmodified lines14114214314414514638 unmodified lines18518618718818919019119219319419519619719819920020120245 unmodified linesgpu_add_list = []def chat(id, npc, prompt):return "AI ์๋ต์ ๋๋ค."def register(id, pw):if id in account_list:48 unmodified lines# Blockchain codedef get_peers(name):data = requests.get("https://health.petals.dev/api/v1/state").json()out = []for d in data['model_reports']:if d['name'] == "petals-team/StableBeluga2":for r in d['server_rows']:out.append(r['peer_id'])return out1 unmodified lineblockchain = Blockchain()def add_transaction(id, kind, data):blockchain.new_transaction(id, kind, data)def proof(name):peers = get_peers(name)for p in gpu_add_list:if not p in peers:add_transaction(get_id_from_p2p(peer), "out", 0)def get_coin(id):c = blockchain.get_user_balance(id)12 unmodified linesreturn outputwith gr.Blocks() as demo:count = 0aa = gr.Interface(38 unmodified linesdescription="add_p, id๋ก p2p id ์ถ๊ฐ. ok ๋ฐํ. \n /run/predict_5",)gc = gr.Interface(fn=get_coin,inputs=["text"],outputs="text",description="get_coin, id๋ก ์์ฌ ์ฝ์ธ(ํ๋๋ ฅ) ๋ฐํ. \n /run/predict_6",)gd = gr.Interface(fn=get_data,inputs=[],outputs="text",description="get_data, ์๊ฐํ์ฉ ๋ชจ๋ ๋ฐ์ดํฐ ๋ฐํ. gpu๊ธฐ์ฌ ๋ชฉ๋ก, total/used, chain \n /run/predict_7",)demo.queue(max_size=32).launch(enable_queue=True)45 unmodified lines46474849505148 unmodified lines1001011021031041051061071081091101111 unmodified line11311411511611711811912012112212312412512612712812912 unmodified lines14214314414514614714814915015115215315415515615715815916016116238 unmodified lines20120220320420520620720820921021121221321421521621721821922022122222322422545 unmodified linesgpu_add_list = []def register(id, pw):if id in account_list:48 unmodified lines# Blockchain codemodel_name = "petals-team/StableBeluga2"def get_peers(model_name):data = requests.get("https://health.petals.dev/api/v1/state").json()out = []for d in data['model_reports']:if d['name'] == model_name:for r in d['server_rows']:out.append(r['peer_id'])return out1 unmodified lineblockchain = Blockchain()def add_transaction(id, kind, data):if kind == "add" or kind == "inference" or kind == "out":blockchain.new_transaction(id, kind, data)return "ok"else:return "fail"def proof(model_name):peers = get_peers(model_name)for p in gpu_add_list:if not p in peers:add_transaction(get_id_from_p2p(peer), "out", 0)def get_coin(id):c = blockchain.get_user_balance(id)12 unmodified linesreturn outputdef chat(id, npc, prompt):if blockchain.get_coin(id) == 0:return "no coin"# model inferenceoutput = "AI ์๋ต์ ๋๋ค."add_transaction(id, "inference", {"prompt":prompt, "output":output})if len(blockchain.current_transactions)>=10:proof(model_name)new_block = blockchain.new_block()return outputwith gr.Blocks() as demo:count = 0aa = gr.Interface(38 unmodified linesdescription="add_p, id๋ก p2p id ์ถ๊ฐ. ok ๋ฐํ. \n /run/predict_5",)addp = gr.Interface(fn=add_transaction,inputs=["text", "text", "text"],outputs="text",description="add_transaction \n /run/predict_6",)gc = gr.Interface(fn=get_coin,inputs=["text"],outputs="text",description="get_coin, id๋ก ์์ฌ ์ฝ์ธ(ํ๋๋ ฅ) ๋ฐํ. \n /run/predict_7",)gd = gr.Interface(fn=get_data,inputs=[],outputs="text",description="get_data, ์๊ฐํ์ฉ ๋ชจ๋ ๋ฐ์ดํฐ ๋ฐํ. gpu๊ธฐ์ฌ ๋ชฉ๋ก, total/used, chain \n /run/predict_8",)demo.queue(max_size=32).launch(enable_queue=True)
app.py+35-12