Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
# Set the theme
|
4 |
-
gr.Interface.load_theme(gr.themes.Soft())
|
5 |
|
6 |
# Initialize the InferenceClient
|
7 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
8 |
|
9 |
-
# The base of this project is made by ehristoforu
|
10 |
-
# This code was mostly written by vericudebuget and gpt-4
|
11 |
-
|
12 |
def format_prompt(message, history):
|
13 |
prompt = "<s>"
|
14 |
for user_prompt, bot_response in history:
|
@@ -39,13 +34,6 @@ def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=904
|
|
39 |
yield output
|
40 |
return output
|
41 |
|
42 |
-
for response in stream:
|
43 |
-
output += response.token.text
|
44 |
-
if "http" in output: # assuming the AI writes a direct image link in its response
|
45 |
-
yield {"image": output} # Gradio will display the image
|
46 |
-
else:
|
47 |
-
yield output
|
48 |
-
|
49 |
additional_inputs = [
|
50 |
gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
|
51 |
gr.Slider(label="Temperature", value=0.9, minimum=0.0, maximum=1.0, step=0.05, interactive=True, info="Higher values produce more diverse outputs"),
|
@@ -62,4 +50,4 @@ gr.Interface(
|
|
62 |
description="Remember! The AI might give incorrect information about people, locations, history, etc...",
|
63 |
concurrency_limit=20,
|
64 |
theme=gr.themes.Soft() # Set the theme here
|
65 |
-
).launch(show_api=False,)
|
|
|
1 |
import gradio as gr
|
2 |
+
from mistral_client import InferenceClient
|
|
|
|
|
3 |
|
4 |
# Initialize the InferenceClient
|
5 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
6 |
|
|
|
|
|
|
|
7 |
def format_prompt(message, history):
|
8 |
prompt = "<s>"
|
9 |
for user_prompt, bot_response in history:
|
|
|
34 |
yield output
|
35 |
return output
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
additional_inputs = [
|
38 |
gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
|
39 |
gr.Slider(label="Temperature", value=0.9, minimum=0.0, maximum=1.0, step=0.05, interactive=True, info="Higher values produce more diverse outputs"),
|
|
|
50 |
description="Remember! The AI might give incorrect information about people, locations, history, etc...",
|
51 |
concurrency_limit=20,
|
52 |
theme=gr.themes.Soft() # Set the theme here
|
53 |
+
).launch(show_api=False,)
|