alanwnl commited on
Commit
585ff59
1 Parent(s): fb16faf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -5
app.py CHANGED
@@ -5,15 +5,32 @@ from langchain.chat_models import ChatOpenAI
5
  from langchain.agents.agent_types import AgentType
6
 
7
  import pandas as pd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- form = st.sidebar.form(key='my_form')
10
- user_api_key = form.text_input(
11
- label="#### Your OpenAI API key 👇",
12
- placeholder="Paste your openAI API key, sk-",
13
- type="password")
14
  uploaded_file = form.file_uploader("Choose a file")
15
  text_prompt = form.text_area('Text Prompt', value='Hello, how are you?')
16
  submit_button = form.form_submit_button(label='Submit')
 
 
 
 
17
  if submit_button :
18
  df = pd.read_csv(uploaded_file)
19
 
@@ -28,6 +45,13 @@ if submit_button :
28
  st.markdown("""---""")
29
 
30
  st.subheader("AI generated response:")
 
 
 
 
 
 
 
31
 
32
  agent = create_pandas_dataframe_agent(
33
  ChatOpenAI(temperature=0, model="gpt-3.5-turbo-16k", openai_api_key=user_api_key),
 
5
  from langchain.agents.agent_types import AgentType
6
 
7
  import pandas as pd
8
+ from langchain.llms import AzureOpenAI
9
+
10
+ import os
11
+
12
+ os.environ["OPENAI_API_TYPE"] = "azure"
13
+ os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"
14
+ os.environ["OPENAI_API_BASE"] = "https://api.hku.hk"
15
+ os.environ["OPENAI_API_KEY"] = "6c6a1a46606c45f2b7b67d8796cf068a"
16
+
17
+ # Import Azure OpenAI
18
+ from langchain.llms import AzureOpenAI
19
+
20
+ # Create an instance of Azure OpenAI
21
+ # Replace the deployment name with your own
22
+ llm = AzureOpenAI(
23
+ deployment_name="gpt-35-turbo",
24
+ model_name="chatgpt",
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
 
 
45
  st.markdown("""---""")
46
 
47
  st.subheader("AI generated response:")
48
+
49
+
50
+ # Send a message to the model
51
+ response = llm("Tell me a joke")
52
+
53
+ # Print the response
54
+ print(response)
55
 
56
  agent = create_pandas_dataframe_agent(
57
  ChatOpenAI(temperature=0, model="gpt-3.5-turbo-16k", openai_api_key=user_api_key),