Spaces:
Running
Running
Update app.py
Browse fileschange styling
app.py
CHANGED
|
@@ -7,15 +7,6 @@ import time
|
|
| 7 |
import tempfile
|
| 8 |
from huggingface_hub import InferenceClient
|
| 9 |
|
| 10 |
-
DESCRIPTION = """ # <center><b>DorjGPT⚡</b></center>
|
| 11 |
-
### <center>A personal Assistant
|
| 12 |
-
"""
|
| 13 |
-
|
| 14 |
-
MORE = """ ## TRY Other Models
|
| 15 |
-
### Instant Video: Create Amazing Videos in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Video
|
| 16 |
-
### Instant Image: 4k images in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Image
|
| 17 |
-
"""
|
| 18 |
-
|
| 19 |
Fast = """## Fastest Model"""
|
| 20 |
|
| 21 |
Complex = """## Best in Complex Question"""
|
|
@@ -24,9 +15,9 @@ Detail = """## Best for Detailed Generation or Long Answers"""
|
|
| 24 |
|
| 25 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 26 |
|
| 27 |
-
system_instructions1 = "<s>[SYSTEM] You are AI assistant named DorjGPT, 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. The request asks you to provide friendly responses as if super interlligent AI assistant. The expectation is that I 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]"
|
| 28 |
|
| 29 |
-
async def generate1(prompt):
|
| 30 |
generate_kwargs = dict(
|
| 31 |
temperature=0.6,
|
| 32 |
max_new_tokens=256,
|
|
@@ -49,21 +40,24 @@ async def generate1(prompt):
|
|
| 49 |
await communicate.save(tmp_path)
|
| 50 |
yield tmp_path
|
| 51 |
|
| 52 |
-
with gr.Blocks(
|
| 53 |
-
gr.
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
output_audio = gr.Audio(label="DorjGPT", type="filepath",
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
| 62 |
translate_btn = gr.Button("Response")
|
| 63 |
translate_btn.click(fn=generate1, inputs=user_input,
|
| 64 |
outputs=output_audio, api_name="translate")
|
| 65 |
-
|
| 66 |
-
gr.Markdown(MORE)
|
| 67 |
|
| 68 |
if __name__ == "__main__":
|
| 69 |
-
demo.queue(max_size=
|
|
|
|
| 7 |
import tempfile
|
| 8 |
from huggingface_hub import InferenceClient
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
Fast = """## Fastest Model"""
|
| 11 |
|
| 12 |
Complex = """## Best in Complex Question"""
|
|
|
|
| 15 |
|
| 16 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 17 |
|
| 18 |
+
system_instructions1 = "<s>[SYSTEM] You are AI assistant named DorjGPT, developed by Dorjzodovsuren. 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. The request asks you to provide friendly responses as if super interlligent AI assistant. The expectation is that I 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]"
|
| 19 |
|
| 20 |
+
async def generate1(prompt, a=None, b=None):
|
| 21 |
generate_kwargs = dict(
|
| 22 |
temperature=0.6,
|
| 23 |
max_new_tokens=256,
|
|
|
|
| 40 |
await communicate.save(tmp_path)
|
| 41 |
yield tmp_path
|
| 42 |
|
| 43 |
+
with gr.Blocks(theme="gradio/monochrome", title="Dorj Assistant") as demo:
|
| 44 |
+
gr.HTML("""
|
| 45 |
+
<h1 style="text-align: center; style="font-size: 3m;">
|
| 46 |
+
DorjGPT
|
| 47 |
+
</h1>
|
| 48 |
+
""")
|
| 49 |
+
with gr.Column():
|
| 50 |
output_audio = gr.Audio(label="DorjGPT", type="filepath",
|
| 51 |
+
interactive=False,
|
| 52 |
+
autoplay=True,
|
| 53 |
+
elem_classes="audio")
|
| 54 |
+
|
| 55 |
+
user_input = gr.Textbox(label="Prompt", value="What is Mongolia")
|
| 56 |
+
with gr.Tab():
|
| 57 |
+
with gr.Row():
|
| 58 |
translate_btn = gr.Button("Response")
|
| 59 |
translate_btn.click(fn=generate1, inputs=user_input,
|
| 60 |
outputs=output_audio, api_name="translate")
|
|
|
|
|
|
|
| 61 |
|
| 62 |
if __name__ == "__main__":
|
| 63 |
+
demo.queue(max_size=30).launch()
|