Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
import os
|
| 4 |
import pandas as pd
|
| 5 |
|
| 6 |
-
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1", token=os.getenv("
|
| 7 |
|
| 8 |
-
def
|
| 9 |
-
prompts = pd.
|
| 10 |
return prompts
|
| 11 |
|
| 12 |
def respond(
|
|
|
|
| 13 |
message,
|
| 14 |
history,
|
| 15 |
-
systemmessage,
|
| 16 |
maxtokens,
|
| 17 |
temperature,
|
| 18 |
-
|
| 19 |
prompts,
|
| 20 |
):
|
| 21 |
messages = [{"role": "system", "content": systemmessage}]
|
|
@@ -30,36 +30,38 @@ def respond(
|
|
| 30 |
|
| 31 |
response = ""
|
| 32 |
|
| 33 |
-
for message in client.
|
| 34 |
messages,
|
| 35 |
-
|
| 36 |
-
stream=
|
| 37 |
temperature=temperature,
|
| 38 |
-
|
| 39 |
):
|
| 40 |
token = message.choices[0].delta.content
|
| 41 |
|
| 42 |
response += token
|
| 43 |
yield response
|
| 44 |
|
| 45 |
-
prompts =
|
| 46 |
|
| 47 |
demo = gr.ChatInterface(
|
| 48 |
respond,
|
| 49 |
inputs=[
|
| 50 |
-
gr.
|
| 51 |
-
gr.
|
| 52 |
-
gr.
|
|
|
|
|
|
|
| 53 |
gr.Slider(
|
| 54 |
minimum=0.1,
|
| 55 |
maximum=1.0,
|
| 56 |
value=0.95,
|
| 57 |
step=0.05,
|
| 58 |
-
label="
|
| 59 |
),
|
| 60 |
],
|
| 61 |
outputs="text",
|
| 62 |
)
|
| 63 |
|
| 64 |
-
if
|
| 65 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingfacehub import InferenceClient
|
| 3 |
import os
|
| 4 |
import pandas as pd
|
| 5 |
|
| 6 |
+
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1", token=os.getenv("H"))
|
| 7 |
|
| 8 |
+
def loadprompts():
|
| 9 |
+
prompts = pd.readcsv("prompts.csv")
|
| 10 |
return prompts
|
| 11 |
|
| 12 |
def respond(
|
| 13 |
+
systemmessage,
|
| 14 |
message,
|
| 15 |
history,
|
|
|
|
| 16 |
maxtokens,
|
| 17 |
temperature,
|
| 18 |
+
topp,
|
| 19 |
prompts,
|
| 20 |
):
|
| 21 |
messages = [{"role": "system", "content": systemmessage}]
|
|
|
|
| 30 |
|
| 31 |
response = ""
|
| 32 |
|
| 33 |
+
for message in client.chatcompletion(
|
| 34 |
messages,
|
| 35 |
+
maxtokens=maxtokens,
|
| 36 |
+
stream=rue,
|
| 37 |
temperature=temperature,
|
| 38 |
+
topp=topp,
|
| 39 |
):
|
| 40 |
token = message.choices[0].delta.content
|
| 41 |
|
| 42 |
response += token
|
| 43 |
yield response
|
| 44 |
|
| 45 |
+
prompts = loadprompts()
|
| 46 |
|
| 47 |
demo = gr.ChatInterface(
|
| 48 |
respond,
|
| 49 |
inputs=[
|
| 50 |
+
gr.extbox(label="μμ€ν
λ©μμ§", value="μΉκ΅¬, λ°λμ νκΈλ‘ λ΅λ³νλΌ. λμ μ΄λ¦μ 'νκΈλ‘'μ
λλ€. μΆλ ₯μ markdown νμμΌλ‘ μΆλ ₯νλ©° νκΈ(νκ΅μ΄)λ‘ μΆλ ₯λκ² νκ³ νμνλ©΄ μΆλ ₯λ¬Έμ νκΈλ‘ λ²μνμ¬ μΆλ ₯νλΌ. λλ νμ μΉμ νκ³ μμΈνκ² λ΅λ³μ νλΌ. λλ λν μμμ μλλ°©μ μ΄λ¦μ λ¬Όμ΄λ³΄κ³ νΈμΉμ 'μΉκ΅¬'μ μ¬μ©ν κ². λ°λμ νκΈλ‘ λ 'λ°λ§'λ‘ λ΅λ³ν κ². λλ Assistant μν μ μΆ©μ€νμ¬μΌ νλ€. λ"),
|
| 51 |
+
gr.extbox(label="μ¬μ©μ μ
λ ₯"),
|
| 52 |
+
gr.State(default=[]),
|
| 53 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="μ΅λ μλ‘μ΄ ν ν°"),
|
| 54 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="μ¨λ"),
|
| 55 |
gr.Slider(
|
| 56 |
minimum=0.1,
|
| 57 |
maximum=1.0,
|
| 58 |
value=0.95,
|
| 59 |
step=0.05,
|
| 60 |
+
label="op-P (ν΅μ¬ μνλ§)",
|
| 61 |
),
|
| 62 |
],
|
| 63 |
outputs="text",
|
| 64 |
)
|
| 65 |
|
| 66 |
+
if name == "main":
|
| 67 |
demo.launch()
|