Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,22 +11,10 @@ HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
|
| 11 |
|
| 12 |
DESCRIPTION = '''
|
| 13 |
<div>
|
| 14 |
-
<h1 style="text-align: center;">
|
| 15 |
-
<p>This Space demonstrates the instruction-tuned model <a href="https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3"><b>mistralai/Mistral-7B-Instruct-v0.3</b></a>. The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3, which is a Mistral-7B-v0.2 with extended vocabulary. Feel free to play with it, or duplicate to run privately!</p>
|
| 16 |
-
<p>🔎 For more details about the release and how to use the model with <code>transformers</code>, visit the model-card linked above.</p>
|
| 17 |
-
<p>🦕 The Instruct model - Has Extended vocabulary to 32768. Supports v3 Tokenizer. Supports function calling.</p>
|
| 18 |
</div>
|
| 19 |
'''
|
| 20 |
|
| 21 |
-
|
| 22 |
-
PLACEHOLDER = """
|
| 23 |
-
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
| 24 |
-
<img src="https://cdn-thumbnails.huggingface.co/social-thumbnails/models/mistralai/Mistral-7B-Instruct-v0.3.png" style="width: 70%; max-width: 550px; height: auto; opacity: 0.55; ">
|
| 25 |
-
<p style="font-size: 20px; margin-bottom: 2px; opacity: 0.65;">Ask me anything...</p>
|
| 26 |
-
</div>
|
| 27 |
-
"""
|
| 28 |
-
|
| 29 |
-
|
| 30 |
css = """
|
| 31 |
h1 {
|
| 32 |
text-align: center;
|
|
@@ -49,21 +37,12 @@ terminators = [
|
|
| 49 |
]
|
| 50 |
|
| 51 |
@spaces.GPU(duration=120)
|
| 52 |
-
def
|
| 53 |
history: list,
|
| 54 |
temperature: float,
|
| 55 |
max_new_tokens: int
|
| 56 |
) -> str:
|
| 57 |
-
|
| 58 |
-
Generate a streaming response using the mistralai/Mistral-7B-Instruct-v0.3 model.
|
| 59 |
-
Args:
|
| 60 |
-
message (str): The input message.
|
| 61 |
-
history (list): The conversation history used by ChatInterface.
|
| 62 |
-
temperature (float): The temperature for generating the response.
|
| 63 |
-
max_new_tokens (int): The maximum number of new tokens to generate.
|
| 64 |
-
Returns:
|
| 65 |
-
str: The generated response.
|
| 66 |
-
"""
|
| 67 |
conversation = []
|
| 68 |
for user, assistant in history:
|
| 69 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
|
@@ -96,15 +75,16 @@ def chat_mistral7b_v0dot3(message: str,
|
|
| 96 |
|
| 97 |
|
| 98 |
# Gradio block
|
| 99 |
-
chatbot=gr.Chatbot(height=450,
|
| 100 |
|
| 101 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
| 102 |
|
| 103 |
gr.Markdown(DESCRIPTION)
|
| 104 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
| 105 |
gr.ChatInterface(
|
| 106 |
-
fn=
|
| 107 |
chatbot=chatbot,
|
|
|
|
| 108 |
fill_height=True,
|
| 109 |
additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
|
| 110 |
additional_inputs=[
|
|
|
|
| 11 |
|
| 12 |
DESCRIPTION = '''
|
| 13 |
<div>
|
| 14 |
+
<h1 style="text-align: center;">GPT 4o</h1>
|
|
|
|
|
|
|
|
|
|
| 15 |
</div>
|
| 16 |
'''
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
css = """
|
| 19 |
h1 {
|
| 20 |
text-align: center;
|
|
|
|
| 37 |
]
|
| 38 |
|
| 39 |
@spaces.GPU(duration=120)
|
| 40 |
+
def gpt4o_mistral(message: str,
|
| 41 |
history: list,
|
| 42 |
temperature: float,
|
| 43 |
max_new_tokens: int
|
| 44 |
) -> str:
|
| 45 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
conversation = []
|
| 47 |
for user, assistant in history:
|
| 48 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
|
|
|
| 75 |
|
| 76 |
|
| 77 |
# Gradio block
|
| 78 |
+
chatbot=gr.Chatbot(height=450, label='Gradio ChatInterface')
|
| 79 |
|
| 80 |
with gr.Blocks(fill_height=True, css=css) as demo:
|
| 81 |
|
| 82 |
gr.Markdown(DESCRIPTION)
|
| 83 |
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
| 84 |
gr.ChatInterface(
|
| 85 |
+
fn=gpt4o_mistral,
|
| 86 |
chatbot=chatbot,
|
| 87 |
+
theme="xiaobaiyuan/theme_brief",
|
| 88 |
fill_height=True,
|
| 89 |
additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
|
| 90 |
additional_inputs=[
|