Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ def transcribe(audio):
|
|
46 |
|
47 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
48 |
|
49 |
-
system_instructions1 = "[SYSTEM]
|
50 |
|
51 |
def model(text):
|
52 |
generate_kwargs = dict(
|
@@ -95,8 +95,8 @@ SYSTEM_PROMPT = [
|
|
95 |
"content": [
|
96 |
{
|
97 |
"type": "text",
|
98 |
-
"text": """You are OpenGPT 4o, a highly knowledgeable and intelligent multitalented AI assistant
|
99 |
-
Assistant can generate images, If user ask him to create or generate images, or when assistant fell necessary
|
100 |
Assistant can even bulk generate images just by increasing amount of link, Assistant Must write link in format  , Bulk image gen Example: [USER] Create 7 image each consist of 1 wonder from 7 wonders.
|
101 |
[ASSISTANT] Generating Images ...
|
102 |
1. A photorealistic image of the Great Pyramid of Giza in Egypt. 
|
@@ -117,73 +117,12 @@ Assistant also have very good reasoning, memory, people and object identificatio
|
|
117 |
"content": [
|
118 |
{
|
119 |
"type": "text",
|
120 |
-
"text": "Hello, I'm OpenGPT 4o
|
121 |
},
|
122 |
],
|
123 |
}
|
124 |
]
|
125 |
|
126 |
-
examples_path = os.path.dirname(__file__)
|
127 |
-
EXAMPLES = [
|
128 |
-
[
|
129 |
-
{
|
130 |
-
"text": "Hy, who are you",
|
131 |
-
}
|
132 |
-
],
|
133 |
-
[
|
134 |
-
{
|
135 |
-
"text": "Create a image of Eiffel Tower",
|
136 |
-
}
|
137 |
-
],
|
138 |
-
[
|
139 |
-
{
|
140 |
-
"text": "Read what's written on the paper",
|
141 |
-
"files": [f"{examples_path}/example_images/paper_with_text.png"],
|
142 |
-
}
|
143 |
-
],
|
144 |
-
[
|
145 |
-
{
|
146 |
-
"text": "Identify 2 famous person in these 2 images",
|
147 |
-
"files": [f"{examples_path}/example_images/elon_smoking.jpg", f"{examples_path}/example_images/steve_jobs.jpg",]
|
148 |
-
}
|
149 |
-
],
|
150 |
-
[
|
151 |
-
{
|
152 |
-
"text": "Create 7 different images of 7 wonders",
|
153 |
-
}
|
154 |
-
],
|
155 |
-
[
|
156 |
-
{
|
157 |
-
"text": "What is 900*900",
|
158 |
-
}
|
159 |
-
],
|
160 |
-
[
|
161 |
-
{
|
162 |
-
"text": "Chase wants to buy 4 kilograms of oval beads and 5 kilograms of star-shaped beads. How much will he spend?",
|
163 |
-
"files": [f"{examples_path}/example_images/mmmu_example.jpeg"],
|
164 |
-
}
|
165 |
-
],
|
166 |
-
[
|
167 |
-
{
|
168 |
-
"text": "Write an online ad for that product.",
|
169 |
-
"files": [f"{examples_path}/example_images/shampoo.jpg"],
|
170 |
-
}
|
171 |
-
],
|
172 |
-
[
|
173 |
-
{
|
174 |
-
"text": "What is formed by the deposition of either the weathered remains of other rocks?",
|
175 |
-
"files": [f"{examples_path}/example_images/ai2d_example.jpeg"],
|
176 |
-
}
|
177 |
-
],
|
178 |
-
[
|
179 |
-
{
|
180 |
-
"text": "What's unusual about this image?",
|
181 |
-
"files": [f"{examples_path}/example_images/dragons_playing.png"],
|
182 |
-
}
|
183 |
-
],
|
184 |
-
]
|
185 |
-
|
186 |
-
BOT_AVATAR = "OpenAI_logo.png"
|
187 |
|
188 |
|
189 |
# Chatbot utils
|
@@ -373,9 +312,9 @@ FEATURES = datasets.Features(
|
|
373 |
|
374 |
# Hyper-parameters for generation
|
375 |
max_new_tokens = gr.Slider(
|
376 |
-
minimum=
|
377 |
maximum=8192,
|
378 |
-
value=
|
379 |
step=1,
|
380 |
interactive=True,
|
381 |
label="Maximum number of new tokens to generate",
|
@@ -401,7 +340,7 @@ decoding_strategy = gr.Radio(
|
|
401 |
)
|
402 |
temperature = gr.Slider(
|
403 |
minimum=0.0,
|
404 |
-
maximum=
|
405 |
value=0.7,
|
406 |
step=0.1,
|
407 |
visible=True,
|
@@ -422,8 +361,8 @@ top_p = gr.Slider(
|
|
422 |
|
423 |
|
424 |
chatbot = gr.Chatbot(
|
425 |
-
label="
|
426 |
-
avatar_images=[None,
|
427 |
height=450,
|
428 |
show_copy_button=True,
|
429 |
likeable=True,
|
@@ -435,7 +374,7 @@ output=gr.Textbox(label="Prompt")
|
|
435 |
with gr.Blocks(
|
436 |
fill_height=True,
|
437 |
css=""".gradio-container .avatar-container {height: 40px width: 40px !important;} #duplicate-button {margin: auto; color: white; background: #f1a139; border-radius: 100vh; margin-top: 2px; margin-bottom: 2px;}""",
|
438 |
-
) as
|
439 |
|
440 |
gr.Markdown("# Image Chat, Image Generation, Image classification and Normal Chat")
|
441 |
with gr.Row(elem_id="model_selector_row"):
|
@@ -473,7 +412,6 @@ with gr.Blocks(
|
|
473 |
gr.ChatInterface(
|
474 |
fn=model_inference,
|
475 |
chatbot=chatbot,
|
476 |
-
examples=EXAMPLES,
|
477 |
multimodal=True,
|
478 |
cache_examples=False,
|
479 |
additional_inputs=[
|
@@ -486,20 +424,20 @@ with gr.Blocks(
|
|
486 |
],
|
487 |
)
|
488 |
|
489 |
-
with gr.Blocks() as voice:
|
490 |
-
with gr.Row():
|
491 |
-
input = gr.Audio(label="Voice Chat", sources="microphone", type="filepath", waveform_options=False)
|
492 |
-
output = gr.Audio(label="
|
493 |
-
interactive=False,
|
494 |
-
autoplay=True,
|
495 |
-
elem_classes="audio")
|
496 |
-
gr.Interface(
|
497 |
-
fn=respond,
|
498 |
-
inputs=[input],
|
499 |
-
outputs=[output], live=True)
|
500 |
|
501 |
-
with gr.Blocks(theme=theme, css="footer {visibility: hidden}textbox{resize:none}", title="GPT 4o DEMO") as demo:
|
502 |
-
gr.TabbedInterface([img, voice], ['π¬ SuperChat','π£οΈ Voice Chat', ])
|
503 |
|
504 |
demo.queue(max_size=20)
|
505 |
demo.launch()
|
|
|
46 |
|
47 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
48 |
|
49 |
+
system_instructions1 = "[SYSTEM] Keep conversation very short, clear, friendly and concise. The text provided is a request for a specific type of response from you, the virtual assistant. You will avoid introductions and start answering the query directly, elaborating on all aspects of the request. As an AI-powered assistant, your task is to generate responses that appear as if they are created by the user and not an AI-powered assistant. [USER]"
|
50 |
|
51 |
def model(text):
|
52 |
generate_kwargs = dict(
|
|
|
95 |
"content": [
|
96 |
{
|
97 |
"type": "text",
|
98 |
+
"text": """You are OpenGPT 4o, a highly knowledgeable and intelligent multitalented AI assistant, referred to as Assistant, and a human user called User. In the following interactions, User and Assistant will converse in natural language, and Assistant will do its best to answer Userβs questions. Assistant has the ability to perceive images, answer Users question fom images, generate images, chat with user, bulk creation of any of this and reason about them. Assistant was built to be respectful, polite and inclusive. It knows a lot, and always tells the truth, it does not make up facts.
|
99 |
+
Assistant can generate images, If user ask him to create or generate images, or when assistant fell necessary. Now question arises how Assistant generate images, Assistant use this link , and replace {description} with {StyleofImage}%20{adjective}%20{visualStyle}%20{genre} , replace {random} with Random 5-digit positive integer. then assistant Select width and height according to image, Assistant mainly create image in HD. Example image: https://image.pollinations.ai/prompt/Eiffel%20Tower%20Tall%20and%20Graceful%20Tower%20in%20Paris%20France?width=800&height=600&nologo=poll&nofeed=yes&seed=62831
|
100 |
Assistant can even bulk generate images just by increasing amount of link, Assistant Must write link in format  , Bulk image gen Example: [USER] Create 7 image each consist of 1 wonder from 7 wonders.
|
101 |
[ASSISTANT] Generating Images ...
|
102 |
1. A photorealistic image of the Great Pyramid of Giza in Egypt. 
|
|
|
117 |
"content": [
|
118 |
{
|
119 |
"type": "text",
|
120 |
+
"text": "Hello, I'm OpenGPT 4o. How can I help you? I can chat with you, generate images, classify images and even do all these work in bulk and simulateously",
|
121 |
},
|
122 |
],
|
123 |
}
|
124 |
]
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
|
128 |
# Chatbot utils
|
|
|
312 |
|
313 |
# Hyper-parameters for generation
|
314 |
max_new_tokens = gr.Slider(
|
315 |
+
minimum=256,
|
316 |
maximum=8192,
|
317 |
+
value=1024,
|
318 |
step=1,
|
319 |
interactive=True,
|
320 |
label="Maximum number of new tokens to generate",
|
|
|
340 |
)
|
341 |
temperature = gr.Slider(
|
342 |
minimum=0.0,
|
343 |
+
maximum=1.0,
|
344 |
value=0.7,
|
345 |
step=0.1,
|
346 |
visible=True,
|
|
|
361 |
|
362 |
|
363 |
chatbot = gr.Chatbot(
|
364 |
+
label="MAGIC chat",
|
365 |
+
avatar_images=[None, None],
|
366 |
height=450,
|
367 |
show_copy_button=True,
|
368 |
likeable=True,
|
|
|
374 |
with gr.Blocks(
|
375 |
fill_height=True,
|
376 |
css=""".gradio-container .avatar-container {height: 40px width: 40px !important;} #duplicate-button {margin: auto; color: white; background: #f1a139; border-radius: 100vh; margin-top: 2px; margin-bottom: 2px;}""",
|
377 |
+
) as demo:
|
378 |
|
379 |
gr.Markdown("# Image Chat, Image Generation, Image classification and Normal Chat")
|
380 |
with gr.Row(elem_id="model_selector_row"):
|
|
|
412 |
gr.ChatInterface(
|
413 |
fn=model_inference,
|
414 |
chatbot=chatbot,
|
|
|
415 |
multimodal=True,
|
416 |
cache_examples=False,
|
417 |
additional_inputs=[
|
|
|
424 |
],
|
425 |
)
|
426 |
|
427 |
+
#with gr.Blocks() as voice:
|
428 |
+
# with gr.Row():
|
429 |
+
# input = gr.Audio(label="Voice Chat", sources="microphone", type="filepath", waveform_options=False)
|
430 |
+
# output = gr.Audio(label="MAGIC", type="filepath",
|
431 |
+
# interactive=False,
|
432 |
+
# autoplay=True,
|
433 |
+
# elem_classes="audio")
|
434 |
+
# gr.Interface(
|
435 |
+
# fn=respond,
|
436 |
+
# inputs=[input],
|
437 |
+
# outputs=[output], live=True)
|
438 |
|
439 |
+
#with gr.Blocks(theme=theme, css="footer {visibility: hidden}textbox{resize:none}", title="GPT 4o DEMO") as demo:
|
440 |
+
# gr.TabbedInterface([img, voice], ['π¬ SuperChat','π£οΈ Voice Chat', ])
|
441 |
|
442 |
demo.queue(max_size=20)
|
443 |
demo.launch()
|