meta-introspector / https-streamlit.io-community-llm-hackathon-2023

hackathon
Apache License 2.0
0 stars 1 forks source link

repl #37

Open jmikedupont2 opened 9 months ago

jmikedupont2 commented 9 months ago

I see what you mean now. You want the Streamlit app to be able to modify its own functions. Here's a way to achieve that:

  1. Define the functions with default values in a separate Python module (let's call it app_functions.py).
  2. In your Streamlit app, import these functions.
  3. Create an interface in your Streamlit app that allows users to modify the function parameters.
  4. Based on user input, call the functions with the modified parameters.

Here's a simplified example of how you could structure your Streamlit app to achieve this:

# app_functions.py
def my_function(parameter1="default_value1", parameter2="default_value2"):
    # Your function logic here
    return f"Parameter1: {parameter1}, Parameter2: {parameter2}"

# main.py
import streamlit as st
from app_functions import my_function

# Define user-modifiable parameters
parameter1 = st.text_input("Parameter 1", "default_value1")
parameter2 = st.text_input("Parameter 2", "default_value2")

# Create a button to execute the function
if st.button("Execute Function"):
    result = my_function(parameter1, parameter2)
    st.write("Function Output:", result)

In this setup, users can input new values for parameter1 and parameter2 in the Streamlit app, and when they click the "Execute Function" button, it will call my_function with the modified parameters and display the result.

You can adapt this structure to your specific use case by defining more functions in app_functions.py and creating a UI to modify their parameters in your Streamlit app.