Skip to content

Prevent chat() function from downloading images. #1431

Closed as not planned
Closed as not planned
@aniketwdubey

Description

Is there a way for the chat() function in the pandasai library to return image responses in a way that they can be displayed directly on a Streamlit app without triggering a download?

I'm currently developing a Streamlit application that utilizes the pandasai library for data analysis. When I use the chat() function to generate image responses, it results in the images being downloaded instead of being displayed on the page. My goal is to have these images shown directly in the app interface for better user experience.

Here’s a snippet of my code:

import pandas as pd
from pandasai import SmartDataframe
from langchain_groq.chat_models import ChatGroq
import os
import streamlit as st

# groq
llm = ChatGroq(model_name="llama3-70b-8192", api_key=os.environ["GROQ_API_KEY"])

# Streamlit app setup
st.title("Data Analysis with SmartDataframe")

df = pd.read_excel('data.xlsx')
df = SmartDataframe(df, config={"llm": llm})

st.write("Smart Dataframe")

# User input for chat command
user_input = st.text_input("Enter your command:")

if user_input:  # Check if user input is provided
    response = df.chat(user_input)  # Get response from SmartDataframe
    # Assuming response is an image URL or path
    st.image(response, use_container_width=True)  # This line triggers the download

Alternatives

No response

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions