semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Updating Streamlit Python Sample to support newest version of SK

Open aaronba opened this issue 11 months ago • 0 comments

Motivation and Context

Follow-up to Issue: https://github.com/microsoft/semantic-kernel/issues/3213

Description

This Python script is a Streamlit application that uses the Semantic Kernel library to create a chatbot that can analyze and answer questions about CSV data.

Here's a step-by-step summary:

The script imports necessary libraries and initializes the Semantic Kernel with the AzureChatCompletion service.

It sets up a Streamlit interface with a title and instructions for the user.

The user can upload a CSV file via the sidebar. The uploaded file is read into a pandas DataFrame, and the first few rows are analyzed using the Semantic Kernel's "AnalyzeDataframe" function.

If the user clicks the "Check Dataframe" button, the application confirms whether the DataFrame has been analyzed and displays the first few rows.

The user can enter a message in the chat form and send it. When the "Send" button is clicked, the message is processed as a prompt.

The prompt is modified using the "DecipherPrompt" function, and then code is generated using the "GenerateCode" function.

The generated response is parsed to extract the code and the explanation. The code is executed, and if there are any errors, the "CodeRepair" function is invoked to try to fix the code. This process is attempted up to three times.

Contribution Checklist

aaronba avatar Mar 26 '24 01:03 aaronba