logo

Web UI smackdown: assessing python frameworks for AI prototyping

Ofer Helman, Data & AI Tech-Lead at Kaltura

2023-09-06

6 min read

In the last few months, generative AI services like ChatGPT have exploded onto the tech scene, dramatically changing how many of us work and create. These powerful new AI tools from companies like Anthropic, OpenAI, and others, have given everyone from students to programmers to marketers the incredible new ability to generate human-like text and code with just a simple prompt.   

  

However, as remarkable as this new technology is, it also comes with significant limitations and risks that we are still learning to address properly. One of the most impactful current issues with AI like ChatGPT is its tendency to "hallucinate", i.e., to make up plausible but incorrect or nonsensical information when it doesn't actually know the answer to a question. This can result in believable but inaccurate content that potentially misleads or harms users if relied upon blindly without human oversight.  

  

As AI and machine learning engineers, my colleagues and I are working hard to help our company successfully leverage these powerful but imperfect new tools. Our job is to find creative ways to tightly integrate AI into products and workflows, maximizing efficiency, accuracy, and speed, while also developing effective guardrails to prevent hallucinations and other errors.  

  

Prototyping & Experimenting with AI   

Recently, we (Kaltura) have been experimenting with different AI technologies to integrate them into its products.

One example is a video search engine that can be used to find specific information within videos. This was made possible by GenAI, which enables us to build special-purpose search engines much more easily.

Another example is an AI-powered assistant that enhances the user experience across our products. This assistant understands user intent and provides personalized recommendations to help users discover relevant content more easily.

Overall, our aim is to use AI to improve our products and services by making them more efficient, user-friendly, and engaging  (we don't use any customer data to train the AI tools, of course).

 

Putting Web Tools to the Test for AI POC 


As engineers, it's crucial that we stay up-to-date on emerging technologies and understand how to apply them to evolving product needs. To demonstrate the value of new generative AI capabilities, we need to build end-to-end POCs rapidly.  

  

In exploring web UI tools to test new technologies, try new workflows and showcase my AI work through compelling interfaces and demos, I looked for options that met several key criteria:  

  

  1. Fast and easy to learn: Minimizes the ramp-up time needed to get started with the platform.
  2. Fully featured: Includes the full range of functionality needed to build robust front-end applications. 
  3. Good development experience: Makes creating, testing, and deploying intuitive and frictionless. 
  4. Large community support: Has an active user base to ask questions and find pre-built components.
  5. Deployment and cloud hosting options: Has the ability to publish easily and host apps.  

  

To evaluate different frameworks hands-on, I set out to create a proof-of-concept chatbot that could search the internet to provide relevant results (SearchBot). For this evaluation, I tested out the following web UI options by spending a few hours using each:  

  

  • Streamlit    
  • Gradio  
  • Taipy  
  • Shiny  
  • Datapane  

  

For each one, I relied on code snippets found online, documentation, and other available resources. Within the limited timeframe, I was not aiming to learn each platform deeply but to gauge the potential for rapidly generating a simple yet functioning AI demo app.  

  

The key factors I assessed were:  

  

  • Ease of setting up and starting development 
  • Availability of relevant code examples and templates   
  • Intuitiveness of the API for my use case 
  • Quality of documentation and community support  

  

This hands-on evaluation helped reveal which frameworks enabled moving fastest from blank slate to initial prototype. While not a fully comprehensive technical review, it provided valuable insights into which options might best suit fast-paced AI application development and iteration.  

 

Streamlit 

Streamlit is a Python-based framework for building web apps for machine learning and data science. It is a free and open-source library that allows you to easily create and share interactive web applications directly from Python scripts. It eliminates the need to learn complex JavaScript coding with descriptive text, model outputs, data visualizations, and UI elements. Streamlit is user-friendly, secure, and rapid to develop and deploy.  

  

Streamlit has a large and growing community with over 1,770 StackOverflow questions answered, enabling easy access to code snippets and examples.  

 

Some key advantages I found with Streamlit:  

  

  1. Quick to get started and learn: The API is intuitive with great documentation. 
  2. Active open-source development, including recently added seamless support for LangChain and other LLMs.
  3. Live app reloading as you edit code: Changes appear instantly in the browser.   
  4. Frictionless cloud deployment of public GitHub repos in minutes.  

  

One downside of Streamlit is that it rerenders the entire app on every data change, which can cause some slowness in larger apps. But overall, Streamlit provides an excellent framework with minimal overhead to build and iterate on AI demo apps rapidly. 

  

The active community also enables finding solutions to any roadblocks quickly. Between the ease of use, tight LLM integration, and cloud deployment, Streamlit has become my #1 choice for creating compelling web experiences to showcase generative AI capabilities in action.  

   

Taipy 

Taipy is an open-source Python library to build your applications’ front- and back-end. Taipy GUI is one of the components of Taipy to create web applications quickly. Taipy brings best practices in terms of what-if analysis with a powerful Scenario Management module and an intuitive KPI monitoring approach.  

  

Taipy offers unique capabilities beyond web UI development that make it worth evaluating. In addition to its front-end framework, it includes Taipy Core – a module for pipeline orchestration, modeling workflows with DAGs, caching, tracking, and more.   

  

However, Taipy still appears to be in the earlier stages of maturity compared to alternatives. During my testing, some documentation and code examples pointed to Streamlit rather than Taipy. I was unable to find ready-made chatbot examples or quickly create one myself within a few hours of exploration.  

  

The Taipy API utilizes a combination of Markdown, HTML, and Python, providing more styling control than just Python but may be less intuitive for developers without web development expertise.  

  

Taipy offers auto-reloading for rapid iteration during development. However, I found the live reloading relatively slow compared to other options.  

  

Overall, Taipy shows promise in bringing together UI development, workflow orchestration, and ML ops. It seems to still be in the relatively early stages of ecosystem maturity.  

 

For developers focused purely on building great web experiences for AI demo applications, other choices like Streamlit currently offer a faster path to productivity based on community size and documentation quality. Taipy's broader feature set may make it appealing for teams needing to orchestrate and monitor complex ML pipelines. It's worth tracking Taipy's progress as the community grows.   

  

Gradio 

Gradio is an open-source Python library that enables you to quickly create customizable UI components around your machine-learning models, neural networks, and other functions.  

  

Hugging Face's Gradio library has become a leading option for building web UIs for AI models quickly. I found the API very intuitive – I was able to easily adapt a chatbot example into a custom search bot I needed, by modifying just a few lines of Python code.   

  

Gradio's seamless integration with Hugging Face Transformers and other ML libraries makes connecting UIs to powerful pre-trained models straightforward. Hosting apps also appear simple with Hugging Face's integrated Spaces platform, though I haven't tested this personally.  

  

Gradio benefits from an established, rapidly growing community. The Gradio-tools library, for example, provides convenient wrappers for tighter integration with LangChain and other modern AI capabilities.  

  

After testing, I believe Gradio provides a robust framework to rapidly develop, deploy and iterate on web interfaces for AI models. The API is thoughtfully designed for Python-based development. With Hugging Face's backing and extensive community support, Gradio offers a mature, reliable platform for showcasing AI through intuitive web apps.  

 

I would feel confident building on Gradio for production use cases, not just prototypes. The extensive resources and help available also enable quickly overcoming any hurdles faced along the way.  

 

  

Shiny  

Shiny promises easy web apps for data science without compromises. While I wasn't able to get Shiny to implement the exact search bot functionality I wanted in the limited time allotted, I found that the external chatstream library (https://github.com/wch/chatstream) provided useful chatbot examples and templates. With more time to work through these, I believe Shiny could support building the demo I had envisioned.  

  

The core Shiny API felt somewhat challenging to maintain and extend compared to other options, as UI elements need to be nested within various container and layout objects. However, Shiny does provide performance benefits – only UI components dependent on data changes are rerendered, enabling much faster overall responsiveness.  

  

Shiny enables controlling HTML elements directly via Python, supporting agile development. There is also a very appealing free cloud hosting option at https://www.shinyapps.io/ to deploy apps easily.  

  

In summary, while Shiny's API may involve a steeper initial learning curve, the performance advantages of Python-based HTML control and free hosting make it a platform worth considering, especially with supplementary libraries like chatstream. The examples and templates available can overcome the initial hurdles of getting started.  

 

While it wasn't the right fit to quickly piece together my specific demo, Shiny remains a capable framework for robust interactive web applications in Python.   

 

Conclusion 

My evaluation of various Python web frameworks for rapidly developing AI demo applications revealed the following: 

  • Streamlit and Gradio are easy to use, have full feature sets, and are polished. Both frameworks can be used to create a functioning chatbot prototype quickly. Streamlit is slightly more intuitive out of the box, while Gradio benefits from tight integration with Hugging Face. 
  • Taipy shows promise, especially for teams needing both UI and ML pipeline capabilities. However, it is in an earlier stage of development than Streamlit and Gradio. Taipy is worth keeping an eye on as its ecosystem evolves. 
  • Datapane is an excellent choice for data exploration and visualization, but it is less optimized for building highly dynamic web apps. For AI prototyping, other options like Streamlit are currently better suited. 
  • Shiny provides a powerful framework but likely requires more time to learn its full capabilities. It may be better for larger, more complex applications than quick prototypes.
     

Overall, each framework has strengths making it a strong competitor in its own right for different use cases.

 

This first-hand experience revealed key factors to consider when selecting a web framework for rapid AI application development and iteration. The right toolkit can accelerate taking an idea from conception to initial prototype quickly and intuitively.

Our Newsletter

  Subscribe to our newsletter and get notified on our latest content                        and events   

Want to take part in knowledge sharing?

We would love to hear from you if you are interested in joining our mission to enrich the ecosystem with knowledge and insights, if you have questions, if there is something you think everyone should know, let us know!

 

Our Newsletter

Subscribe to our newsletter and get                notified on our latest content                          and events 

Want to take part in knowledge sharing?

We would love to hear from you if you are interested in joining our mission to enrich the ecosystem with knowledge and insights, if there is something you think everyone should know, let us know!

 

More articles from the blog

Looking to relaunch your brand? Follow these 3 crucial steps

Lauren Gumport

03/04/2024

6 min read

Personal Lessons on Maximizing Impact with Minimal Resources

David balsam

27/03/2024

4 min read

The Art of Lean Team Building: Practical Strategies for Startups

Daria Rudnik, Team Architect

14/09/2023

4 min read