Zekun Wu commited on
Commit
16a4a07
1 Parent(s): 2b50455
Files changed (1) hide show
  1. app.py +27 -9
app.py CHANGED
@@ -55,18 +55,36 @@ class GPTAgent:
55
  return response.choices[0].message.content
56
 
57
  # Streamlit app interface
58
- st.title('Model Invocation with User Credentials')
59
 
60
  model_type = st.radio("Select the type of agent", ('AzureAgent', 'GPTAgent'))
61
  api_key = st.text_input("API Key", type="password")
62
  endpoint_url = st.text_input("Endpoint URL")
63
 
64
- input_text = st.text_area('Enter your text')
65
- if st.button('Invoke Model'):
66
- if model_type == 'AzureAgent':
67
- agent = AzureAgent(api_key, endpoint_url)
68
- else:
69
- agent = GPTAgent(api_key, endpoint_url)
 
70
 
71
- output = agent.invoke(input_text, temperature=0, max_tokens=5)
72
- st.write('Response:', output)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  return response.choices[0].message.content
56
 
57
  # Streamlit app interface
58
+ st.title('Model Invocation with Dataset Processing')
59
 
60
  model_type = st.radio("Select the type of agent", ('AzureAgent', 'GPTAgent'))
61
  api_key = st.text_input("API Key", type="password")
62
  endpoint_url = st.text_input("Endpoint URL")
63
 
64
+ # File upload and data display
65
+ uploaded_file = st.file_uploader("Choose a file")
66
+ if uploaded_file is not None:
67
+ # Read data
68
+ data = StringIO(uploaded_file.getvalue().decode("utf-8"))
69
+ df = pd.read_csv(data)
70
+ st.write('Uploaded Data:', df.head())
71
 
72
+ # Process data button
73
+ if st.button('Process Data'):
74
+ if model_type == 'AzureAgent':
75
+ agent = AzureAgent(api_key, endpoint_url)
76
+ else:
77
+ agent = GPTAgent(api_key, endpoint_url)
78
+
79
+ # Example processing step (adapt as needed)
80
+ df['Response'] = df['Input Column'].apply(lambda x: agent.invoke(x, temperature=0, max_tokens=150))
81
+
82
+ st.write('Processed Data:', df.head())
83
+
84
+ # Generate download link
85
+ st.download_button(
86
+ label="Download processed data",
87
+ data=df.to_csv().encode('utf-8'),
88
+ file_name='processed_data.csv',
89
+ mime='text/csv',
90
+ )