Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,7 @@ def main():
|
|
| 23 |
|
| 24 |
csv_files = st.file_uploader("Upload CSV files", type="csv", accept_multiple_files=True)
|
| 25 |
if csv_files:
|
| 26 |
-
llm = OpenAI(api_key=api_key, temperature=0, max_tokens=
|
| 27 |
user_input = st.text_input("Question here:")
|
| 28 |
|
| 29 |
# Iterate over each CSV file
|
|
@@ -36,15 +36,6 @@ def main():
|
|
| 36 |
# Perform any necessary data preprocessing or feature engineering here
|
| 37 |
# You can modify the code based on your specific requirements
|
| 38 |
|
| 39 |
-
# Example: Accessing columns from the DataFrame
|
| 40 |
-
# column_data = df["column_name"]
|
| 41 |
-
|
| 42 |
-
# Example: Applying transformations or calculations to the data
|
| 43 |
-
# transformed_data = column_data.apply(lambda x: x * 2)
|
| 44 |
-
|
| 45 |
-
# Example: Using the preprocessed data with the OpenAI API
|
| 46 |
-
# llm_response = llm.predict(transformed_data)
|
| 47 |
-
|
| 48 |
if user_input:
|
| 49 |
# Pass the user input to the OpenAI agent for processing
|
| 50 |
agent = create_csv_agent(llm, f.name, verbose=True)
|
|
@@ -52,7 +43,10 @@ def main():
|
|
| 52 |
|
| 53 |
st.write(f"CSV File: {csv_file.name}")
|
| 54 |
st.write("Response:")
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# Add links to the sidebar with the same spacing properties
|
| 58 |
st.sidebar.markdown("<p class='sidebar-link'>π <a href='https://chandrakalagowda-demo2.hf.space/'> PDF Bot </a></p>", unsafe_allow_html=True)
|
|
|
|
| 23 |
|
| 24 |
csv_files = st.file_uploader("Upload CSV files", type="csv", accept_multiple_files=True)
|
| 25 |
if csv_files:
|
| 26 |
+
llm = OpenAI(api_key=api_key, temperature=0, max_tokens=1000, output_format="list") # Adjust max_tokens as needed
|
| 27 |
user_input = st.text_input("Question here:")
|
| 28 |
|
| 29 |
# Iterate over each CSV file
|
|
|
|
| 36 |
# Perform any necessary data preprocessing or feature engineering here
|
| 37 |
# You can modify the code based on your specific requirements
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
if user_input:
|
| 40 |
# Pass the user input to the OpenAI agent for processing
|
| 41 |
agent = create_csv_agent(llm, f.name, verbose=True)
|
|
|
|
| 43 |
|
| 44 |
st.write(f"CSV File: {csv_file.name}")
|
| 45 |
st.write("Response:")
|
| 46 |
+
|
| 47 |
+
# Create a foldable section for long outputs
|
| 48 |
+
with st.beta_expander("Show Full Response"):
|
| 49 |
+
st.write(response)
|
| 50 |
|
| 51 |
# Add links to the sidebar with the same spacing properties
|
| 52 |
st.sidebar.markdown("<p class='sidebar-link'>π <a href='https://chandrakalagowda-demo2.hf.space/'> PDF Bot </a></p>", unsafe_allow_html=True)
|