Download app.py from miminions/MiFactory: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/miminions/MiFactory/resolve/main/app.py
- Command line
-
hf download hf://spaces/miminions/MiFactory/app.py
-
curl -L -o app.py https://huggingface.co/spaces/miminions/MiFactory/resolve/main/app.py
1.74 kB
| import gradio as gr | |
| from supplier import * | |
| from tools import material_manager, project_manager | |
| BASE_SAMPLES = ["What can you help me with?","What materials do we have?","What projects do we have today?"] | |
| # create a system setting for llm | |
| with gr.Blocks() as supply_chain_view: | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Label("Projects") | |
| project_table = gr.Dataframe(project_manager.get_items()) | |
| with gr.Column(): | |
| gr.Label("Materials") | |
| material_table = gr.DataFrame(material_manager.get_items()) | |
| with gr.Blocks() as chat_window: | |
| with gr.Row(): | |
| with gr.Column(): | |
| chatbot = gr.Chatbot([]) | |
| chatbot_speech = gr.Audio() | |
| with gr.Column(): | |
| chat_clear = gr.Button("Clear") | |
| play_speech = gr.Button("Play") | |
| chat_clear.click(lambda:None,None,chatbot,queue=False) | |
| play_speech.click(text_to_audio,chatbot,chatbot_speech,queue=False) | |
| with gr.Column(): | |
| msg = gr.Textbox() | |
| submit = gr.Button("Submit") | |
| gr.Examples(BASE_SAMPLES,msg,label="Examples") | |
| audio = gr.Audio(sources="microphone",type="filepath") | |
| audio.change(transcript,audio,msg,queue=False) | |
| msg.submit(send_chat,[msg,chatbot],[msg,chatbot]) | |
| submit.click(send_chat,[msg,chatbot],[msg,chatbot],queue=False) | |
| iface = gr.TabbedInterface( | |
| [chat_window,supply_chain_view], | |
| ["Chat","Supply Chain View"], | |
| title="MiMinions.ai", | |
| css="footer {visibility: hidden}") | |
| if __name__ == "__main__": | |
| iface.launch( | |
| auth=[ ("admin","hello world"), | |
| ("guest","p@55word")], | |
| server_port=8000, | |
| ) |