Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
-
|
| 4 |
-
"""
|
| 5 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
-
"""
|
| 7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 8 |
|
| 9 |
|
|
@@ -28,27 +24,24 @@ def respond(
|
|
| 28 |
response = ""
|
| 29 |
|
| 30 |
for message in client.chat_completion(
|
| 31 |
-
messages,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
):
|
| 33 |
token = message.choices[0].delta.content
|
| 34 |
|
| 35 |
response += token
|
| 36 |
yield response
|
| 37 |
|
| 38 |
-
|
| 39 |
-
"""
|
| 40 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 41 |
-
"""
|
| 42 |
demo = gr.ChatInterface(
|
| 43 |
respond,
|
| 44 |
additional_inputs=[
|
| 45 |
-
gr.Textbox(value="
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
label="**Response format:**",
|
| 50 |
-
placeholder="Specify how you want the output presented (e.g., list, code, essay)",
|
| 51 |
-
),
|
| 52 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 53 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 54 |
gr.Slider(
|
|
@@ -63,4 +56,4 @@ demo = gr.ChatInterface(
|
|
| 63 |
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 4 |
|
| 5 |
|
|
|
|
| 24 |
response = ""
|
| 25 |
|
| 26 |
for message in client.chat_completion(
|
| 27 |
+
messages,
|
| 28 |
+
max_tokens=max_tokens,
|
| 29 |
+
stream=True,
|
| 30 |
+
temperature=temperature,
|
| 31 |
+
top_p=top_p,
|
| 32 |
):
|
| 33 |
token = message.choices[0].delta.content
|
| 34 |
|
| 35 |
response += token
|
| 36 |
yield response
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
demo = gr.ChatInterface(
|
| 39 |
respond,
|
| 40 |
additional_inputs=[
|
| 41 |
+
gr.Textbox(value="Act as an expert in prompt engineering. Your task is to deeply understand what the user wants, and in return respond with a well-crafted prompt that, if fed to a separate AI, will get the exact result the user desires. ### Task: {task} ### Context: Make sure to include *any* context that is needed for the LLM to accurately, and reliably respond as needed. ### Response format: Outline the ideal response format for this prompt. ### Important Notes: - Instruct the model to list out its thoughts before giving an answer. - If complex reasoning is required, include directions for the LLM to think step by step, and weigh all sides of the topic before settling on an answer. - Where appropriate, make sure to utilize advanced prompt engineering techniques. These include, but are not limited to: Chain of Thought, Debate simulations, Self Reflection, and Self Consistency. - Strictly use text, no code please ### Input: [Type here what you want from the model]", label="System message"),
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
|
|
|
|
|
|
|
|
|
| 45 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 46 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 47 |
gr.Slider(
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
if __name__ == "__main__":
|
| 59 |
+
demo.launch()
|