pgleeson commited on
Commit
a41e4c6
·
1 Parent(s): 7c5e275

Update to use openworm_ai>=0.3.1

Browse files
Files changed (5) hide show
  1. app.py +16 -11
  2. requirements.txt +2 -4
  3. ring.py +6 -10
  4. test.py +12 -11
  5. test.sh +15 -0
app.py CHANGED
@@ -5,16 +5,20 @@ import streamlit as st
5
 
6
  from ring import PREF_ORDER_LLMS
7
 
8
- from ring import requires_openai_key
9
- from ring import get_openai_api_key
10
  from ring import generate_response
11
  from ring import generate_panel_response
12
 
13
  from openworm_ai import __version__ as openworm_ai_version
14
 
 
 
15
  import socket
16
 
17
- __version__ = "0.4.8"
 
 
 
 
18
 
19
 
20
  col1, col2 = st.columns([3, 1])
@@ -24,7 +28,10 @@ with col1:
24
  st.markdown(
25
  "Testing the use of LLMs and other AI technology for _C. elegans_ research and computational modelling of the worm. Part of the [OpenWorm](https://openworm.org) project."
26
  )
27
- st.markdown("**v%s** (openworm_ai **v%s**) - Note: this is a work in progress!" % (__version__, openworm_ai_version))
 
 
 
28
 
29
  with col2:
30
  st.image("images/OpenWormLogo.png")
@@ -74,17 +81,17 @@ with tab_free:
74
 
75
  temperature = st.text_input("Temperature", value=0.1)
76
 
77
- allow_all_topics = 'MBP' in socket.gethostname()
78
 
79
  only_celegans = st.checkbox(
80
- "Only answer questions related to _C. elegans_", value=not allow_all_topics, disabled=not allow_all_topics
 
 
81
  )
82
 
83
  submitted = st.form_submit_button("Submit")
84
 
85
- if requires_openai_key(llm_ver) and not get_openai_api_key():
86
- st.info("Please add your OpenAI API key to continue.")
87
- elif submitted:
88
  response = generate_response(text, llm_ver, temperature, only_celegans)
89
 
90
  st.info(response)
@@ -137,8 +144,6 @@ with tab_panel:
137
  st.markdown("Please choose a panelist that is not the panel lead.")
138
  elif len(selected_options) == 0:
139
  st.markdown("Please choose one or more panelists to join the panel lead.")
140
- elif requires_openai_key(llm_ver) and not get_openai_api_key():
141
- st.info("Please add your OpenAI API key to continue.")
142
  elif submitted:
143
  # Create new list of LLMs that does not include panel lead
144
  llm_panelists = [llm for llm in selected_options if llm != panel_lead]
 
5
 
6
  from ring import PREF_ORDER_LLMS
7
 
 
 
8
  from ring import generate_response
9
  from ring import generate_panel_response
10
 
11
  from openworm_ai import __version__ as openworm_ai_version
12
 
13
+ from openworm_ai.utils.llms import OPENAI_LLMS
14
+
15
  import socket
16
 
17
+ __version__ = "0.5.0"
18
+
19
+
20
+ def requires_openai_key(llm_ver):
21
+ return llm_ver in OPENAI_LLMS
22
 
23
 
24
  col1, col2 = st.columns([3, 1])
 
28
  st.markdown(
29
  "Testing the use of LLMs and other AI technology for _C. elegans_ research and computational modelling of the worm. Part of the [OpenWorm](https://openworm.org) project."
30
  )
31
+ st.markdown(
32
+ "GUI **v%s** (openworm_ai **v%s**) - Note: this is a work in progress!"
33
+ % (__version__, openworm_ai_version)
34
+ )
35
 
36
  with col2:
37
  st.image("images/OpenWormLogo.png")
 
81
 
82
  temperature = st.text_input("Temperature", value=0.1)
83
 
84
+ allow_all_topics = "MBP" in socket.gethostname()
85
 
86
  only_celegans = st.checkbox(
87
+ "Only answer questions related to _C. elegans_",
88
+ value=not allow_all_topics,
89
+ disabled=not allow_all_topics,
90
  )
91
 
92
  submitted = st.form_submit_button("Submit")
93
 
94
+ if submitted:
 
 
95
  response = generate_response(text, llm_ver, temperature, only_celegans)
96
 
97
  st.info(response)
 
144
  st.markdown("Please choose a panelist that is not the panel lead.")
145
  elif len(selected_options) == 0:
146
  st.markdown("Please choose one or more panelists to join the panel lead.")
 
 
147
  elif submitted:
148
  # Create new list of LLMs that does not include panel lead
149
  llm_panelists = [llm for llm in selected_options if llm != panel_lead]
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
 
 
2
  openai
3
  asyncio
4
  wormneuroatlas
@@ -7,8 +8,5 @@ matplotlib
7
  pylems
8
  pyneuroml
9
  langchain-google-genai
10
- langchain_ai21
11
- langchain_anthropic
12
  langchain_cohere
13
- streamlit
14
- openworm-ai[dev]>=0.2.9
 
1
 
2
+ openworm_ai>=0.3.1
3
  openai
4
  asyncio
5
  wormneuroatlas
 
8
  pylems
9
  pyneuroml
10
  langchain-google-genai
 
 
11
  langchain_cohere
12
+ streamlit
 
ring.py CHANGED
@@ -1,18 +1,12 @@
1
  import os
2
 
3
- from langchain.prompts import PromptTemplate
4
  from langchain_core.output_parsers import StrOutputParser
 
5
 
6
  from openworm_ai.utils.llms import GENERAL_QUERY_PROMPT_TEMPLATE
7
- from openworm_ai.utils.llms import GENERAL_QUERY_LIMITED_PROMPT_TEMPLATE
8
 
9
  from openworm_ai.utils.llms import get_llm as get_llm_via_openworm_ai
10
 
11
- from openworm_ai.utils.llms import requires_openai_key
12
- from openworm_ai.utils.llms import get_openai_api_key
13
- from openworm_ai.utils.llms import get_gemini_api_key
14
- from openworm_ai.utils.llms import generate_response
15
-
16
 
17
  from openworm_ai.utils.llms import LLM_GPT35
18
  from openworm_ai.utils.llms import LLM_GPT4
@@ -23,19 +17,21 @@ from openworm_ai.utils.llms import LLM_OLLAMA_MISTRAL
23
  from openworm_ai.utils.llms import LLM_OLLAMA_OLMO2_7B
24
  from openworm_ai.utils.llms import LLM_COHERE
25
 
 
 
26
 
27
  OPENAI_LLMS = [LLM_GPT35, LLM_GPT4, LLM_GPT4o]
28
 
29
  OLLAMA_LLMS = [LLM_OLLAMA_LLAMA32_1B, LLM_OLLAMA_MISTRAL, LLM_OLLAMA_OLMO2_7B]
30
 
31
- OPENWORM_AI_LLMS = [LLM_GEMINI_2F] + OPENAI_LLMS + [LLM_COHERE] # + oLLAMA_LLMS
32
 
33
  LLM_LLAMA2 = "LLAMA2"
34
- LLM_GEMINI = "gemini-1.5-pro"
35
  LLM_CLAUDE2 = "Claude2.1"
36
 
37
 
38
- PREF_ORDER_LLMS = [LLM_GEMINI] + OPENWORM_AI_LLMS # + [LLM_LLAMA2, LLM_CLAUDE2]
39
 
40
 
41
  def get_llamaapi_key():
 
1
  import os
2
 
 
3
  from langchain_core.output_parsers import StrOutputParser
4
+ from langchain_core.prompts import PromptTemplate
5
 
6
  from openworm_ai.utils.llms import GENERAL_QUERY_PROMPT_TEMPLATE
 
7
 
8
  from openworm_ai.utils.llms import get_llm as get_llm_via_openworm_ai
9
 
 
 
 
 
 
10
 
11
  from openworm_ai.utils.llms import LLM_GPT35
12
  from openworm_ai.utils.llms import LLM_GPT4
 
17
  from openworm_ai.utils.llms import LLM_OLLAMA_OLMO2_7B
18
  from openworm_ai.utils.llms import LLM_COHERE
19
 
20
+ from openworm_ai.utils.llms import generate_response
21
+
22
 
23
  OPENAI_LLMS = [LLM_GPT35, LLM_GPT4, LLM_GPT4o]
24
 
25
  OLLAMA_LLMS = [LLM_OLLAMA_LLAMA32_1B, LLM_OLLAMA_MISTRAL, LLM_OLLAMA_OLMO2_7B]
26
 
27
+ OPENWORM_AI_LLMS = [LLM_GEMINI_2F] + OPENAI_LLMS + [LLM_COHERE] # + OLLAMA_LLMS
28
 
29
  LLM_LLAMA2 = "LLAMA2"
30
+ # LLM_GEMINI = "gemini-1.5-pro"
31
  LLM_CLAUDE2 = "Claude2.1"
32
 
33
 
34
+ PREF_ORDER_LLMS = OPENWORM_AI_LLMS # + [LLM_LLAMA2, LLM_CLAUDE2]
35
 
36
 
37
  def get_llamaapi_key():
test.py CHANGED
@@ -1,8 +1,8 @@
1
- from ring import LLM_GPT35
2
- from ring import LLM_LLAMA2
3
- from ring import LLM_GEMINI
4
- from ring import LLM_CLAUDE2
5
- from ring import LLM_COHERE
6
 
7
 
8
  from ring import generate_response
@@ -11,17 +11,18 @@ import sys
11
 
12
  question = "What is the most common type of neuron in the brain?"
13
 
14
- llm_ver = LLM_GPT35
15
 
16
- if "-g" in sys.argv:
17
- llm_ver = LLM_GEMINI
 
 
 
 
18
 
19
  if "-l" in sys.argv:
20
  llm_ver = LLM_LLAMA2
21
 
22
- if "-cl" in sys.argv:
23
- llm_ver = LLM_CLAUDE2
24
-
25
  if "-co" in sys.argv:
26
  llm_ver = LLM_COHERE
27
 
 
1
+ from openworm_ai.utils.llms import LLM_GPT4o
2
+ from openworm_ai.utils.llms import LLM_LLAMA2
3
+ from openworm_ai.utils.llms import LLM_GEMINI_2F
4
+ from openworm_ai.utils.llms import LLM_GEMINI_25F
5
+ from openworm_ai.utils.llms import LLM_COHERE
6
 
7
 
8
  from ring import generate_response
 
11
 
12
  question = "What is the most common type of neuron in the brain?"
13
 
14
+ llm_ver = LLM_GPT4o
15
 
16
+
17
+ if "-g2" in sys.argv:
18
+ llm_ver = LLM_GEMINI_2F
19
+
20
+ if "-g25" in sys.argv:
21
+ llm_ver = LLM_GEMINI_25F
22
 
23
  if "-l" in sys.argv:
24
  llm_ver = LLM_LLAMA2
25
 
 
 
 
26
  if "-co" in sys.argv:
27
  llm_ver = LLM_COHERE
28
 
test.sh ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -ex
3
+
4
+ ruff format *.py
5
+ #ruff check *.py
6
+
7
+ pip install -r requirements.txt
8
+
9
+ python test.py -co
10
+
11
+ echo
12
+ echo " Success!"
13
+ echo
14
+
15
+