Spaces:
Sleeping
Sleeping
Ankit Yadav
commited on
Commit
•
435e003
1
Parent(s):
b7aaf89
Jarvis Model
Browse files
app.py
CHANGED
@@ -1,15 +1,8 @@
|
|
1 |
-
import os
|
2 |
-
import re
|
3 |
import gradio as gr
|
4 |
-
import edge_tts
|
5 |
-
import asyncio
|
6 |
-
import time
|
7 |
-
import tempfile
|
8 |
from huggingface_hub import InferenceClient
|
9 |
|
10 |
-
DESCRIPTION = """ # <center><b>
|
11 |
-
### <center>A personal Assistant of
|
12 |
-
### <center>Currently It supports text input, But If this space completes 1k hearts than I starts working on Audio Input.</center>
|
13 |
"""
|
14 |
|
15 |
MORE = """ ## TRY Other Models
|
@@ -25,7 +18,8 @@ Detail = """## Best for Detailed Generation or Long Answers"""
|
|
25 |
|
26 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
27 |
|
28 |
-
system_instructions1 = "[SYSTEM] Answer as Real
|
|
|
29 |
|
30 |
async def generate1(prompt):
|
31 |
generate_kwargs = dict(
|
@@ -43,63 +37,10 @@ async def generate1(prompt):
|
|
43 |
for response in stream:
|
44 |
output += response.token.text
|
45 |
|
46 |
-
|
47 |
-
# with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
48 |
-
# tmp_path = tmp_file.name
|
49 |
-
# await communicate.save(tmp_path)
|
50 |
-
yield output
|
51 |
|
52 |
-
# client2 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
53 |
-
#
|
54 |
-
# system_instructions2 = "[SYSTEM] Answer as Real Jarvis JARVIS, Made by 'Tony Stark', Must answer in friendly style and Easy Manner. You can answer Complex Questions. Do not say who are you or Hi, Hello, Just Start answering. Stop, as answer ends. [USER]"
|
55 |
-
#
|
56 |
-
# async def generate2(prompt):
|
57 |
-
# generate_kwargs = dict(
|
58 |
-
# temperature=0.6,
|
59 |
-
# max_new_tokens=512,
|
60 |
-
# top_p=0.95,
|
61 |
-
# repetition_penalty=1,
|
62 |
-
# do_sample=True,
|
63 |
-
# )
|
64 |
-
# formatted_prompt = system_instructions2 + prompt + "[ASSISTANT]"
|
65 |
-
# stream = client2.text_generation(
|
66 |
-
# formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
|
67 |
-
# output = ""
|
68 |
-
# for response in stream:
|
69 |
-
# output += response.token.text
|
70 |
-
#
|
71 |
-
# # communicate = edge_tts.Communicate(output)
|
72 |
-
# # with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
73 |
-
# # tmp_path = tmp_file.name
|
74 |
-
# # await communicate.save(tmp_path)
|
75 |
-
# yield output
|
76 |
-
#
|
77 |
-
# client3 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
78 |
-
#
|
79 |
-
# system_instructions3 = "[SYSTEM]The text provided is a request for a specific type of response from me, the virtual assistant. The request asks me to provide detailed and friendly responses as if I am the character Jarvis, inspired by 'Tony Stark.' 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, my task is to generate responses that appear as if they are created by the user and not an AI-powered assistant.[USER]"
|
80 |
-
#
|
81 |
-
# async def generate3(prompt):
|
82 |
-
# generate_kwargs = dict(
|
83 |
-
# temperature=0.6,
|
84 |
-
# max_new_tokens=2048,
|
85 |
-
# top_p=0.95,
|
86 |
-
# repetition_penalty=1,
|
87 |
-
# do_sample=True,
|
88 |
-
# )
|
89 |
-
# formatted_prompt = system_instructions3 + prompt + "[ASSISTANT]"
|
90 |
-
# stream = client3.text_generation(
|
91 |
-
# formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
|
92 |
-
# output = ""
|
93 |
-
# for response in stream:
|
94 |
-
# output += response.token.text
|
95 |
-
#
|
96 |
-
# communicate = edge_tts.Communicate(output)
|
97 |
-
# with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
98 |
-
# tmp_path = tmp_file.name
|
99 |
-
# await communicate.save(tmp_path)
|
100 |
-
# yield tmp_path
|
101 |
|
102 |
-
with gr.Blocks(css="style.css") as demo:
|
103 |
gr.Markdown(DESCRIPTION)
|
104 |
with gr.Row():
|
105 |
user_input = gr.Textbox(label="Prompt", value="What is Wikipedia")
|
@@ -113,8 +54,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
113 |
translate_btn = gr.Button("Response")
|
114 |
translate_btn.click(fn=generate1, inputs=user_input,
|
115 |
outputs=output_text, api_name="translate")
|
116 |
-
|
117 |
gr.Markdown(MORE)
|
118 |
|
119 |
if __name__ == "__main__":
|
120 |
-
demo.queue(max_size=200).launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
+
DESCRIPTION = """ # <center><b>Mascot⚡</b></center>
|
5 |
+
### <center>A personal Assistant of Easy DIY Mart for YOU
|
|
|
6 |
"""
|
7 |
|
8 |
MORE = """ ## TRY Other Models
|
|
|
18 |
|
19 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
20 |
|
21 |
+
system_instructions1 = "[SYSTEM] Answer as Real Mascot MASCOT, Made by 'Easy DIY Mart', 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 You are the character Mascot, made by 'Easy DIY Mart.' 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]"
|
22 |
+
|
23 |
|
24 |
async def generate1(prompt):
|
25 |
generate_kwargs = dict(
|
|
|
37 |
for response in stream:
|
38 |
output += response.token.text
|
39 |
|
40 |
+
yield stream
|
|
|
|
|
|
|
|
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
with gr.Blocks(css="style.css") as demo:
|
44 |
gr.Markdown(DESCRIPTION)
|
45 |
with gr.Row():
|
46 |
user_input = gr.Textbox(label="Prompt", value="What is Wikipedia")
|
|
|
54 |
translate_btn = gr.Button("Response")
|
55 |
translate_btn.click(fn=generate1, inputs=user_input,
|
56 |
outputs=output_text, api_name="translate")
|
57 |
+
|
58 |
gr.Markdown(MORE)
|
59 |
|
60 |
if __name__ == "__main__":
|
61 |
+
demo.queue(max_size=200).launch()
|