Spaces:
Sleeping
Sleeping
Update app.py
Browse files7 unmodified lines8910111112131414 unmodified lines293031323334353632333435404142434436373839484950515253404142434 unmodified lines4849506465515253547 unmodified lines
loop = asyncio.get_event_loop()gradio_client = GrClient('https://ldhldh-demo.hf.space/')gradio_client = GrClient('https://ldhldh-demoforkakaoapi.hf.space/')# Monkey patchdef get_types(cls_set: List[Type], component: str): docset = []14 unmodified linesroutes.get_types = get_types
# App codedef chat(x): x = f"[***λλ Assistantμ
λλ€. μλμκ² λ€μν μ§λ¬Έμ νλ©° λνλ₯Ό μ΄λκ³ μμ΅λλ€. Humanμκ² κΈμ μ μ΄κ³ , 곡κ°νλ©°, μ΅λν κΈΈκ² λλ΅ν΄μ£ΌμΈμ***]\nHuman: {x}\n\n###\nAssistant:"
print("\n___________________\n" + f"{x}") def chat(x): result = gradio_client.predict( x, # str representing input in 'User input' Textbox component 0.91, # float, representing input in 'Top-p (nucleus sampling)' Slider component 10, # int, representing input in 'Top-k (nucleus sampling)' Slider component 0.65, # float, representing input in 'Temperature' Slider component 20, # int, representing input in 'Max New Tokens' Slider component 1.2, # float, representing input in 'repetition_penalty' Slider component 5, fn_index=0 ) result = str(result) output = result[len(x.rsplit(':', 1)[0])+2:] output = re.sub('νν','γ
γ
', output) output = output.split('λ')[0] output = output.split('endoftext')[0] output = re.sub('[=+#/\:@*\"β»γγβ|\\\<\>\(\)\[\]`\'β¦γ\β\β\βΒ·]', '', output) #output = re.sub('[a-zA-Z]',' ',output) output = result[len(x.rsplit(':', 1)[0]):] return output
4 unmodified lines inputs="text", outputs="text", description="chat", #examples= [[f"\nfriend: λλ κΏμ΄ λμΌ? \nyou: "],[f"\nyou: λλ λ¬΄μ¨ μμ κ°μ₯ μ’μν΄? \nfriend: κΈμ λλ? \nyou: "]] examples= [[f"λλ κΏμ΄ λμΌ?"],[f"λλ λ¬΄μ¨ μμ κ°μ₯ μ’μν΄?"]] examples= [[f"λλ κΏμ΄ λμΌ?"],[f"λλ λ¬΄μ¨ μμ κ°μ₯ μ’μν΄?"]] )
demo.queue(max_size=32).launch(enable_queue=True) app.py+5-19