Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import requests, os, re, asyncio
|
|
8 |
|
9 |
|
10 |
loop = asyncio.get_event_loop()
|
11 |
-
gradio_client = GrClient('https://ldhldh-
|
12 |
# Monkey patch
|
13 |
def get_types(cls_set: List[Type], component: str):
|
14 |
docset = []
|
@@ -29,28 +29,15 @@ def get_types(cls_set: List[Type], component: str):
|
|
29 |
routes.get_types = get_types
|
30 |
|
31 |
# App code
|
32 |
-
def chat(x):
|
33 |
-
x = f"[***λλ Assistantμ
λλ€. μλμκ² λ€μν μ§λ¬Έμ νλ©° λνλ₯Ό μ΄λκ³ μμ΅λλ€. Humanμκ² κΈμ μ μ΄κ³ , 곡κ°νλ©°, μ΅λν κΈΈκ² λλ΅ν΄μ£ΌμΈμ***]\nHuman: {x}\n\n###\nAssistant:"
|
34 |
-
|
35 |
-
print("\n___________________\n" + f"{x}")
|
36 |
-
|
37 |
result = gradio_client.predict(
|
38 |
x,
|
39 |
# str representing input in 'User input' Textbox component
|
40 |
-
|
41 |
-
10, # int, representing input in 'Top-k (nucleus sampling)' Slider component
|
42 |
-
0.65, # float, representing input in 'Temperature' Slider component
|
43 |
-
20, # int, representing input in 'Max New Tokens' Slider component
|
44 |
-
1.2, # float, representing input in 'repetition_penalty' Slider component
|
45 |
fn_index=0
|
46 |
)
|
47 |
result = str(result)
|
48 |
-
output = result[len(x.rsplit(':', 1)[0])
|
49 |
-
output = re.sub('νν','γ
γ
', output)
|
50 |
-
output = output.split('λ')[0]
|
51 |
-
output = output.split('endoftext')[0]
|
52 |
-
output = re.sub('[=+#/\:@*\"β»γγβ|\\\<\>\(\)\[\]`\'β¦γ\β\β\βΒ·]', '', output)
|
53 |
-
#output = re.sub('[a-zA-Z]',' ',output)
|
54 |
|
55 |
return output
|
56 |
|
@@ -61,8 +48,7 @@ with gr.Blocks() as demo:
|
|
61 |
inputs="text",
|
62 |
outputs="text",
|
63 |
description="chat",
|
64 |
-
|
65 |
-
examples= [[f"λλ κΏμ΄ λμΌ?"],[f"λλ λ¬΄μ¨ μμ κ°μ₯ μ’μν΄?"]]
|
66 |
)
|
67 |
|
68 |
demo.queue(max_size=32).launch(enable_queue=True)
|
|
|
8 |
|
9 |
|
10 |
loop = asyncio.get_event_loop()
|
11 |
+
gradio_client = GrClient('https://ldhldh-demoforkakaoapi.hf.space/')
|
12 |
# Monkey patch
|
13 |
def get_types(cls_set: List[Type], component: str):
|
14 |
docset = []
|
|
|
29 |
routes.get_types = get_types
|
30 |
|
31 |
# App code
|
32 |
+
def chat(x):
|
|
|
|
|
|
|
|
|
33 |
result = gradio_client.predict(
|
34 |
x,
|
35 |
# str representing input in 'User input' Textbox component
|
36 |
+
5,
|
|
|
|
|
|
|
|
|
37 |
fn_index=0
|
38 |
)
|
39 |
result = str(result)
|
40 |
+
output = result[len(x.rsplit(':', 1)[0]):]
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
return output
|
43 |
|
|
|
48 |
inputs="text",
|
49 |
outputs="text",
|
50 |
description="chat",
|
51 |
+
examples= [[f"λλ κΏμ΄ λμΌ?"],[f"λλ λ¬΄μ¨ μμ κ°μ₯ μ’μν΄?"]]
|
|
|
52 |
)
|
53 |
|
54 |
demo.queue(max_size=32).launch(enable_queue=True)
|