doncamilom commited on
Commit
89cf44e
·
1 Parent(s): 6ba25fd

adding more models from openai

Browse files
Files changed (1) hide show
  1. app.py +23 -12
app.py CHANGED
@@ -39,18 +39,22 @@ st.markdown(
39
  unsafe_allow_html=True,
40
  )
41
 
42
- agent = ChemCrow(
43
- model='gpt-4-0613',
44
- tools_model='gpt-4-turbo-preview',
45
- temp=0.1,
46
- openai_api_key=ss.get('api_key'),
47
- api_keys={
48
- 'RXN4CHEM_API_KEY': st.secrets['RXN4CHEM_API_KEY'],
49
- 'CHEMSPACE_API_KEY': st.secrets['CHEMSPACE_API_KEY']
50
- }
51
- ).agent_executor
52
 
53
- tools = agent.tools
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  tool_list = pd.Series(
56
  {f"✅ {t.name}":t.description for t in tools}
@@ -63,8 +67,8 @@ def on_api_key_change():
63
  if not oai_key_isvalid(api_key):
64
  st.write("Please input a valid OpenAI API key.")
65
 
66
-
67
  def run_prompt(prompt):
 
68
  st.chat_message("user").write(prompt)
69
  with st.chat_message("assistant"):
70
  st_callback = StreamlitCallbackHandlerChem(
@@ -113,6 +117,13 @@ with st.sidebar:
113
  label_visibility="collapsed"
114
  )
115
 
 
 
 
 
 
 
 
116
  # Display prompt examples
117
  st.markdown('# What can I ask?')
118
  cols = st.columns(2)
 
39
  unsafe_allow_html=True,
40
  )
41
 
 
 
 
 
 
 
 
 
 
 
42
 
43
+ def instantiate_agent(model):
44
+ ss.agent = ChemCrow(
45
+ model=model,
46
+ tools_model=model,
47
+ temp=0.1,
48
+ openai_api_key=ss.get('api_key'),
49
+ api_keys={
50
+ 'RXN4CHEM_API_KEY': st.secrets['RXN4CHEM_API_KEY'],
51
+ 'CHEMSPACE_API_KEY': st.secrets['CHEMSPACE_API_KEY']
52
+ }
53
+ ).agent_executor
54
+ return ss.agent
55
+
56
+ instantiate_agent('gpt-4-0613')
57
+ tools = ss.agent.tools
58
 
59
  tool_list = pd.Series(
60
  {f"✅ {t.name}":t.description for t in tools}
 
67
  if not oai_key_isvalid(api_key):
68
  st.write("Please input a valid OpenAI API key.")
69
 
 
70
  def run_prompt(prompt):
71
+ agent = instantiate_agent(ss.get('model_select'))
72
  st.chat_message("user").write(prompt)
73
  with st.chat_message("assistant"):
74
  st_callback = StreamlitCallbackHandlerChem(
 
117
  label_visibility="collapsed"
118
  )
119
 
120
+ # Input model to use
121
+ st.selectbox(
122
+ 'Select model to use',
123
+ ['gpt-4-0613', 'gpt-3.5-turbo', 'gpt-4o-mini'],
124
+ key='model_select',
125
+ )
126
+
127
  # Display prompt examples
128
  st.markdown('# What can I ask?')
129
  cols = st.columns(2)