Spaces:
Sleeping
Sleeping
File size: 2,371 Bytes
01d1dd6 c2f1466 cf7a07e 5aca742 b0d9242 a7feab8 7192ffe f223851 da9b438 c2f1466 628eb7c 9e16fe0 e87ef93 1418034 9e16fe0 5be15aa d79f686 5be15aa f223851 1418034 f223851 9e16fe0 f223851 9e16fe0 ddcca98 |
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
from threading import Thread
import gradio as gr
import inspect
from gradio import routes
from typing import List, Type
import requests, os, re, asyncio, queue
import math
import time
import datetime
import requests, json
from huggingface_hub import hf_hub_download
from llama_cpp import Llama
loop = asyncio.get_event_loop()
# Monkey patch
def get_types(cls_set: List[Type], component: str):
docset = []
types = []
if component == "input":
for cls in cls_set:
doc = inspect.getdoc(cls)
doc_lines = doc.split("\n")
docset.append(doc_lines[1].split(":")[-1])
types.append(doc_lines[1].split(")")[0].split("(")[-1])
else:
for cls in cls_set:
doc = inspect.getdoc(cls)
doc_lines = doc.split("\n")
docset.append(doc_lines[-1].split(":")[-1])
types.append(doc_lines[-1].split(")")[0].split("(")[-1])
return docset, types
routes.get_types = get_types
# App code
account_list = dict()
account_list['id'] = "pass"
name_list = dict()
name_list['id'] = 'name'
def chat(x):
return "AI 응답입니다."
def register(id, pass):
if id in account_list:
return "exist"
else:
account_list[id] = pass
return "ok"
def login(id, pass):
if id in account_list:
if account_list[id] == pass:
return "login"
else:
return "password error"
else:
return "no id"
def add_name(id, name):
name_list[id] = name
return "ok"
def get_name(id):
if id in name_list:
return name_list['id']
else:
return "no id"
with gr.Blocks() as demo:
count = 0
aa = gr.Interface(
fn=chat,
inputs=["text"],
outputs="text",
description="call",
)
rr = gr.Interface(
fn=register,
inputs=["text", "text"],
outputs="text",
description="call",
)
ll = gr.Interface(
fn=login,
inputs=["text", "text"],
outputs="text",
description="call",
)
ad = gr.Interface(
fn=add_name,
inputs=["text", "text"],
outputs="text",
description="call",
)
nn = gr.Interface(
fn=get_name,
inputs=["text"],
outputs="text",
description="call",
)
demo.queue(max_size=32).launch(enable_queue=True) |