Spaces:
Sleeping
Sleeping
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 | |
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 | |
q = queue.Queue() | |
arrr = [] | |
from huggingface_hub import hf_hub_download | |
hf_hub_download(repo_id='StarFox7/Llama-2-ko-7B-chat-gguf', filename='Llama-2-ko-7B-chat-gguf-q4_0.bin', local_dir='./') | |
# App code | |
def res(x, id, cdata, url): | |
global q | |
arr = [x, id, str(cdata.split(",", 1)[0]), url] | |
q.put(arr) | |
arrr.append(x) | |
print("\n_Done\n\n") | |
return "Done" | |
def rese(x): | |
print(f"{arrr}") | |
return "Done" | |
with gr.Blocks() as demo: | |
count = 0 | |
aa = gr.Interface( | |
fn=res, | |
inputs=["text","text", "text", "text"], | |
outputs="text", | |
description="call", | |
) | |
bb = gr.Interface( | |
fn=rese, | |
inputs=["text"], | |
outputs="text", | |
description="call", | |
) | |
demo.queue(max_size=32).launch(enable_queue=True) |