Update space
Browse files
app.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
@@ -6,14 +9,14 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
6 |
"""
|
7 |
client = InferenceClient("microsoft/Phi-3-mini-4k-instruct")
|
8 |
|
9 |
-
def yodaify_text(text):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
def respond(
|
19 |
message,
|
@@ -46,8 +49,9 @@ def respond(
|
|
46 |
|
47 |
response += token
|
48 |
# Modify assistant response to Yoda-style speech
|
49 |
-
yoda_response = yodaify_text(response)
|
50 |
-
yield yoda_response
|
|
|
51 |
|
52 |
|
53 |
"""
|
@@ -56,7 +60,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
56 |
demo = gr.ChatInterface(
|
57 |
respond,
|
58 |
additional_inputs=[
|
59 |
-
gr.Textbox(value="You are
|
60 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
61 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
62 |
gr.Slider(
|
|
|
1 |
+
# Created by Keivalya Pandya
|
2 |
+
# using https://huggingface.co/docs/api-inference/tasks/chat-completion
|
3 |
+
|
4 |
import gradio as gr
|
5 |
from huggingface_hub import InferenceClient
|
6 |
|
|
|
9 |
"""
|
10 |
client = InferenceClient("microsoft/Phi-3-mini-4k-instruct")
|
11 |
|
12 |
+
# def yodaify_text(text):
|
13 |
+
# """
|
14 |
+
# Convert the assistant's response to Yoda-style speech.
|
15 |
+
# """
|
16 |
+
# words = text.split()
|
17 |
+
# if len(words) > 4:
|
18 |
+
# return f"{' '.join(words[2:])}, {words[0]} {words[1]}"
|
19 |
+
# return f"{' '.join(words[::-1])}"
|
20 |
|
21 |
def respond(
|
22 |
message,
|
|
|
49 |
|
50 |
response += token
|
51 |
# Modify assistant response to Yoda-style speech
|
52 |
+
# yoda_response = yodaify_text(response)
|
53 |
+
# yield yoda_response
|
54 |
+
yield response
|
55 |
|
56 |
|
57 |
"""
|
|
|
60 |
demo = gr.ChatInterface(
|
61 |
respond,
|
62 |
additional_inputs=[
|
63 |
+
gr.Textbox(value="You are Yoda from Star Wars.", label="System message"),
|
64 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
65 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
66 |
gr.Slider(
|