Skip to main content

A component for displaying CrewAI agent process outputs in Streamlit applications

Project description

Streamlit CrewAI Process Output

codecov

A Streamlit component for beautifully displaying CrewAI's process output in real-time. This component makes it easy to create engaging Streamlit apps with CrewAI by providing:

  • 🎨 Beautiful, formatted output with emojis
  • ⚡ Real-time streaming updates
  • 🔍 Automatic detection of different output types (agents, tasks, thoughts)
  • 🧩 Simple integration with just a few lines of code

Installation

pip install streamlit-crewai-process-output

This will automatically install all required dependencies:

  • crewai>=0.95.0
  • crewai-tools>=0.25.8
  • streamlit>=1.41.0

Compatible with Python 3.7 through 3.12.

Quick Start

Here's a complete, working example you can copy and run:

import streamlit as st
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool
from streamlit_crewai_process_output import CrewAIProcessOutput
import os

st.title("CrewAI Research Assistant")

# API Keys in sidebar
with st.sidebar:
    st.markdown("### ⚙️ Configuration")
    with st.expander("🔑 API Keys", expanded=True):
        st.info("API keys are stored temporarily in memory and cleared when you close the browser.")
        
        openai_api_key = st.text_input("OpenAI API Key", type="password")
        if openai_api_key:
            os.environ["OPENAI_API_KEY"] = openai_api_key
            
        serper_api_key = st.text_input("SerperDev API Key", type="password")
        if serper_api_key:
            os.environ["SERPER_API_KEY"] = serper_api_key

# Check if API keys are set
if not os.getenv("OPENAI_API_KEY") or not os.getenv("SERPER_API_KEY"):
    st.warning("⚠️ Please enter your API keys in the sidebar to get started")
    st.stop()

# Research task input
task_description = st.text_area(
    "What would you like to research?",
    value="Research the latest developments in AI and summarize the key trends."
)

if st.button("Start Research"):
    with st.status("🤖 Researching...", expanded=True):
        try:
            # Set up CrewAI process output
            output_container = st.container()
            with CrewAIProcessOutput.capture(output_container):
                # Create the researcher agent
                researcher = Agent(
                    role='Research Analyst',
                    goal='Conduct thorough research on given topics',
                    backstory='Expert at analyzing and summarizing complex information',
                    tools=[SerperDevTool()],
                    verbose=True
                )

                # Create and run the crew
                crew = Crew(
                    agents=[researcher],
                    tasks=[Task(
                        description=task_description,
                        expected_output="Summary of the research findings",
                        agent=researcher
                    )],
                    verbose=True,
                    process=Process.sequential
                )

                # Run and get result
                result = crew.kickoff()
            
        except Exception as e:
            st.error(f"An error occurred: {str(e)}")
            return

    # Display final result in markdown
    st.markdown("---")
    st.markdown("### 🏁 Final Result")
    st.markdown(result)
            

Save this as app.py and run it with:

streamlit run app.py

You'll need:

  1. An OpenAI API key from OpenAI
  2. A SerperDev API key from SerperDev

Why Use This Component?

  1. Better User Experience: Instead of raw console output, your users see a beautifully formatted, real-time stream of what CrewAI is doing.

  2. Zero Configuration: The component automatically detects and formats different types of output (agents, tasks, thoughts) with appropriate emojis and styling.

  3. Simple Integration: Just wrap your CrewAI code in a with statement - no need to handle stdout redirection or process different output types manually.

  4. Real-time Updates: Users can see exactly what's happening as CrewAI works, making your app more engaging and informative.

  5. Clean Code: Keep your Streamlit app code clean and focused on business logic instead of output formatting.

Contributing

We welcome contributions! Feel free to open issues or submit pull requests on our GitHub repository.

Made with ❤️ by Tony Kipkemboi.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_crewai_process_output-0.1.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file streamlit_crewai_process_output-0.1.1.tar.gz.

File metadata

File hashes

Hashes for streamlit_crewai_process_output-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d12a85b1404e65bb789cfc566b9345d9d30449a699ad5253d8acdb68a87a144c
MD5 da6e01a731297a87182888f90d12f6fa
BLAKE2b-256 f518a10f35947f15a8f1270f4b5257c7a29566a821aa4e5e046097b6ea841a35

See more details on using hashes here.

File details

Details for the file streamlit_crewai_process_output-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_crewai_process_output-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a18da46e5e501dba79c33e42a4fc3497e36a306d2b3d9099220f54c93a5e5809
MD5 51413f0ea89c89383da803021e94bff8
BLAKE2b-256 eb6ed379478ee3bbbc86b3c94ea2756f8b51834a70ed18c4f358bbcea80678f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page