Isidorophp commited on
Commit
8ff0a94
·
verified ·
1 Parent(s): ee85d5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -29
app.py CHANGED
@@ -26,7 +26,8 @@ def transcribe(audio):
26
 
27
  client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
28
 
29
- system_instructions1 = "<s>[SYSTEM] Answer as Real Jarvis JARVIS, Made by 'Tony Stark', 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 Jarvis, made 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, your task is to generate responses that appear as if they are created by the user and not an AI-powered assistant. [USER]"
 
30
 
31
  def model(text):
32
  generate_kwargs = dict(
@@ -38,7 +39,7 @@ def model(text):
38
  seed=42,
39
  )
40
 
41
- formatted_prompt = system_instructions1 + text + "[JARVIS]"
42
  stream = client1.text_generation(
43
  formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
44
  output = ""
@@ -71,29 +72,11 @@ async def respond(audio):
71
  await communicate.save(tmp_path)
72
  yield tmp_path
73
 
74
- DESCRIPTION = """ # <center><b>JARVIS 🤖 🧠 🧬</b></center>
75
- ### <center>An Artificial Intelligence Assistant for YOU
76
- ### <center>Talk to - JARVIS</center>
77
- """
78
-
79
- MORE = """ ## TRY Other Models
80
- ### Instant Video: Create Amazing Videos in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Video
81
- ### Instant Image: 4k images in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Image
82
- """
83
-
84
- BETA = """ ### Voice Chat"""
85
-
86
- FAST = """## Fastest Model"""
87
-
88
- Complex = """## Best in Complex Question"""
89
 
90
- Detail = """## Best for Detailed Generation or Long Answers"""
91
 
92
- base_loaded = "mistralai/Mixtral-8x7B-Instruct-v0.1"
93
-
94
- client1 = InferenceClient(base_loaded)
95
 
96
- system_instructions1 = "[SYSTEM] Answer as Real Jarvis male male, Assistant to Tony Stark, 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 Jarvis, made 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, your task is to generate responses that appear as if they are created by the user and not an AI-powered assistant. [USER]"
97
 
98
  async def generate1(prompt):
99
  generate_kwargs = dict(
@@ -103,7 +86,7 @@ async def generate1(prompt):
103
  repetition_penalty=1,
104
  do_sample=False,
105
  )
106
- formatted_prompt = system_instructions1 + prompt + "[JARVIS]"
107
  stream = client1.text_generation(
108
  formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
109
  output = ""
@@ -118,10 +101,14 @@ async def generate1(prompt):
118
  yield tmp_path
119
 
120
  with gr.Blocks(css="style.css") as demo:
121
- gr.Markdown(DESCRIPTION)
 
 
 
 
122
  with gr.Row():
123
  user_input = gr.Audio(label="Voice Chat", type="filepath")
124
- output_audio = gr.Audio(label="JARVIS", type="filepath",
125
  interactive=False,
126
  autoplay=True,
127
  elem_classes="audio")
@@ -129,11 +116,11 @@ with gr.Blocks(css="style.css") as demo:
129
  translate_btn = gr.Button("Response")
130
  translate_btn.click(fn=respond, inputs=user_input,
131
  outputs=output_audio, api_name=False)
132
- gr.Markdown(FAST)
133
  with gr.Row():
134
- user_input = gr.Textbox(label="Prompt", value="What's a fun science experiment I can do at home?")
135
  input_text = gr.Textbox(label="Input Text", elem_id="important")
136
- output_audio = gr.Audio(label="JARVIS", type="filepath",
137
  interactive=False,
138
  autoplay=True,
139
  elem_classes="audio")
@@ -142,7 +129,7 @@ with gr.Blocks(css="style.css") as demo:
142
  translate_btn.click(fn=generate1, inputs=user_input,
143
  outputs=output_audio, api_name="translate")
144
 
145
- gr.Markdown(MORE)
146
 
147
  if __name__ == "__main__":
148
  demo.queue(max_size=200).launch()
 
26
 
27
  client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
28
 
29
+ system_instructions1 = "<s>[SYSTEM] Answer as WATSON, Famous Sherlock Holmes Assistant, Keep conversation 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 WATSON From Sherlock Holmes Novels, 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 a Human and not an AI-powered assistant. [USER]"
30
+
31
 
32
  def model(text):
33
  generate_kwargs = dict(
 
39
  seed=42,
40
  )
41
 
42
+ formatted_prompt = system_instructions1 + text + "[WATSON]"
43
  stream = client1.text_generation(
44
  formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
45
  output = ""
 
72
  await communicate.save(tmp_path)
73
  yield tmp_path
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
 
76
 
77
+ client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
 
 
78
 
79
+ system_instructions1 = "[SYSTEM] Answer as Watson with a London accent male voice. You are the character and Assistant Watson, from Sherlock Holmes Novels, 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 Watson, from Sherlock Holmes Novel. 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 a Real Person and not an AI-powered assistant. [USER]"
80
 
81
  async def generate1(prompt):
82
  generate_kwargs = dict(
 
86
  repetition_penalty=1,
87
  do_sample=False,
88
  )
89
+ formatted_prompt = system_instructions1 + prompt + "[WATSON]"
90
  stream = client1.text_generation(
91
  formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
92
  output = ""
 
101
  yield tmp_path
102
 
103
  with gr.Blocks(css="style.css") as demo:
104
+ gr.Markdown(""" # <center><b>Watson 🤖 🧠 🧬</b></center>
105
+ ### <center>An Artificial Intelligence Assistant for YOU
106
+ ### <center>Talk to - Watson</center>
107
+ """)
108
+
109
  with gr.Row():
110
  user_input = gr.Audio(label="Voice Chat", type="filepath")
111
+ output_audio = gr.Audio(label="WATSON", type="filepath",
112
  interactive=False,
113
  autoplay=True,
114
  elem_classes="audio")
 
116
  translate_btn = gr.Button("Response")
117
  translate_btn.click(fn=respond, inputs=user_input,
118
  outputs=output_audio, api_name=False)
119
+
120
  with gr.Row():
121
+ user_input = gr.Textbox(label="Prompt", value="What's a fun science experiment we can do Watson?")
122
  input_text = gr.Textbox(label="Input Text", elem_id="important")
123
+ output_audio = gr.Audio(label="WATSON", type="filepath",
124
  interactive=False,
125
  autoplay=True,
126
  elem_classes="audio")
 
129
  translate_btn.click(fn=generate1, inputs=user_input,
130
  outputs=output_audio, api_name="translate")
131
 
132
+
133
 
134
  if __name__ == "__main__":
135
  demo.queue(max_size=200).launch()