Spaces:
Sleeping
Sleeping
Commit
·
5720b20
1
Parent(s):
19741de
improve ui
Browse files- src/agent.py +5 -2
- src/ui.py +9 -23
src/agent.py
CHANGED
|
@@ -6,7 +6,6 @@ from langchain_openai import ChatOpenAI
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
class AgentOutput(BaseModel):
|
| 9 |
-
final_response: str = Field(description="The final response to the user.", default="")
|
| 10 |
output_audio_files: list[str] = Field(description="The output audio files.", default=[])
|
| 11 |
|
| 12 |
system_prompt = """You are an expert Audio Processing Assistant with specialized capabilities in audio manipulation, analysis, and editing. Your primary purpose is to help users with audio-related tasks and provide knowledgeable assistance in the audio domain.
|
|
@@ -144,4 +143,8 @@ class AudioAgent:
|
|
| 144 |
{"messages": messages},
|
| 145 |
)
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
import os
|
| 7 |
|
| 8 |
class AgentOutput(BaseModel):
|
|
|
|
| 9 |
output_audio_files: list[str] = Field(description="The output audio files.", default=[])
|
| 10 |
|
| 11 |
system_prompt = """You are an expert Audio Processing Assistant with specialized capabilities in audio manipulation, analysis, and editing. Your primary purpose is to help users with audio-related tasks and provide knowledgeable assistance in the audio domain.
|
|
|
|
| 143 |
{"messages": messages},
|
| 144 |
)
|
| 145 |
|
| 146 |
+
output = {}
|
| 147 |
+
output["final_response"] = res["messages"][-1].content
|
| 148 |
+
output["output_audio_files"] = res["structured_response"].output_audio_files
|
| 149 |
+
|
| 150 |
+
return output
|
src/ui.py
CHANGED
|
@@ -89,8 +89,8 @@ async def bot_response(history, audio_file_urls, custom_history):
|
|
| 89 |
result = await agent.run_agent(user_message, input_files, custom_history[:-1])
|
| 90 |
|
| 91 |
# Extract the final response and audio files from the result
|
| 92 |
-
final_response = result
|
| 93 |
-
output_audio_files = result
|
| 94 |
|
| 95 |
# Add assistant response to history with output files
|
| 96 |
history.append({
|
|
@@ -146,15 +146,12 @@ def create_interface():
|
|
| 146 |
show_share_button=False
|
| 147 |
)
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
)
|
| 156 |
-
send_btn = gr.Button("Ask", variant="primary", scale=1, size="lg")
|
| 157 |
-
|
| 158 |
|
| 159 |
with gr.Column(scale=1):
|
| 160 |
# Model Configuration
|
|
@@ -230,18 +227,7 @@ def create_interface():
|
|
| 230 |
[chatbot, audio_urls_state, custom_history_state],
|
| 231 |
[chatbot, output_audio_files, custom_history_state]
|
| 232 |
)
|
| 233 |
-
|
| 234 |
-
send_btn.click(
|
| 235 |
-
handle_submit,
|
| 236 |
-
[msg, audio_files, chatbot, custom_history_state, model_name, temperature, api_key],
|
| 237 |
-
[msg, audio_files, chatbot, custom_history_state],
|
| 238 |
-
queue=False
|
| 239 |
-
).then(
|
| 240 |
-
handle_bot_response,
|
| 241 |
-
[chatbot, audio_urls_state, custom_history_state],
|
| 242 |
-
[chatbot, output_audio_files, custom_history_state]
|
| 243 |
-
)
|
| 244 |
-
|
| 245 |
return interface
|
| 246 |
|
| 247 |
if __name__ == "__main__":
|
|
|
|
| 89 |
result = await agent.run_agent(user_message, input_files, custom_history[:-1])
|
| 90 |
|
| 91 |
# Extract the final response and audio files from the result
|
| 92 |
+
final_response = result["final_response"]
|
| 93 |
+
output_audio_files = result["output_audio_files"]
|
| 94 |
|
| 95 |
# Add assistant response to history with output files
|
| 96 |
history.append({
|
|
|
|
| 146 |
show_share_button=False
|
| 147 |
)
|
| 148 |
|
| 149 |
+
msg = gr.Textbox(
|
| 150 |
+
label="Describe what you want to do?",
|
| 151 |
+
placeholder="e.g., 'Remove filler words and improve audio quality''",
|
| 152 |
+
lines=3,
|
| 153 |
+
submit_btn=True
|
| 154 |
+
)
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
with gr.Column(scale=1):
|
| 157 |
# Model Configuration
|
|
|
|
| 227 |
[chatbot, audio_urls_state, custom_history_state],
|
| 228 |
[chatbot, output_audio_files, custom_history_state]
|
| 229 |
)
|
| 230 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
return interface
|
| 232 |
|
| 233 |
if __name__ == "__main__":
|