Update app.py
Browse files
app.py
CHANGED
|
@@ -17,20 +17,16 @@ os.environ["OPENAI_API_KEY"] = "6c6a1a46606c45f2b7b67d8796cf068a"
|
|
| 17 |
# Import Azure OpenAI
|
| 18 |
from langchain.llms import AzureOpenAI
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
uploaded_file = form.file_uploader("Choose a file")
|
| 28 |
text_prompt = form.text_area('Text Prompt', value='Hello, how are you?')
|
| 29 |
submit_button = form.form_submit_button(label='Submit')
|
| 30 |
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
if submit_button :
|
| 35 |
df = pd.read_csv(uploaded_file)
|
| 36 |
|
|
@@ -46,15 +42,16 @@ if submit_button :
|
|
| 46 |
|
| 47 |
st.subheader("AI generated response:")
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
agent = create_pandas_dataframe_agent(
|
| 57 |
-
|
| 58 |
df,
|
| 59 |
verbose=True,
|
| 60 |
agent_type=AgentType.OPENAI_FUNCTIONS,
|
|
|
|
| 17 |
# Import Azure OpenAI
|
| 18 |
from langchain.llms import AzureOpenAI
|
| 19 |
|
| 20 |
+
form = st.sidebar.form(key='my_form')
|
| 21 |
+
user_api_key = form.text_input(
|
| 22 |
+
label="#### Your OpenAI API key 👇",
|
| 23 |
+
placeholder="Paste your openAI API key, sk-",
|
| 24 |
+
type="password")
|
|
|
|
|
|
|
| 25 |
uploaded_file = form.file_uploader("Choose a file")
|
| 26 |
text_prompt = form.text_area('Text Prompt', value='Hello, how are you?')
|
| 27 |
submit_button = form.form_submit_button(label='Submit')
|
| 28 |
|
| 29 |
|
|
|
|
|
|
|
| 30 |
if submit_button :
|
| 31 |
df = pd.read_csv(uploaded_file)
|
| 32 |
|
|
|
|
| 42 |
|
| 43 |
st.subheader("AI generated response:")
|
| 44 |
|
| 45 |
+
|
| 46 |
+
llm = AzureOpenAI(
|
| 47 |
+
deployment_name="chatgpt",
|
| 48 |
+
model_name="chatgpt",
|
| 49 |
+
openai_api_key=user_api_key,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
|
| 53 |
agent = create_pandas_dataframe_agent(
|
| 54 |
+
llm,
|
| 55 |
df,
|
| 56 |
verbose=True,
|
| 57 |
agent_type=AgentType.OPENAI_FUNCTIONS,
|