Spaces:
Running
Running
To v0.4.4
Browse files
app.py
CHANGED
|
@@ -10,7 +10,9 @@ from ring import get_openai_api_key
|
|
| 10 |
from ring import generate_response
|
| 11 |
from ring import generate_panel_response
|
| 12 |
|
| 13 |
-
__version__
|
|
|
|
|
|
|
| 14 |
|
| 15 |
col1, col2 = st.columns([3, 1])
|
| 16 |
|
|
@@ -19,7 +21,7 @@ with col1:
|
|
| 19 |
st.markdown(
|
| 20 |
"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."
|
| 21 |
)
|
| 22 |
-
st.markdown("**v%s** - Note: this is a work in progress!" % __version__)
|
| 23 |
|
| 24 |
with col2:
|
| 25 |
st.image("images/OpenWormLogo.png")
|
|
|
|
| 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 |
+
__version__ = "0.4.4"
|
| 16 |
|
| 17 |
col1, col2 = st.columns([3, 1])
|
| 18 |
|
|
|
|
| 21 |
st.markdown(
|
| 22 |
"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."
|
| 23 |
)
|
| 24 |
+
st.markdown("**v%s** (openworm_ai **v%s**) - Note: this is a work in progress!" % (__version__, openworm_ai_version))
|
| 25 |
|
| 26 |
with col2:
|
| 27 |
st.image("images/OpenWormLogo.png")
|
ring.py
CHANGED
|
@@ -11,6 +11,7 @@ from openworm_ai.utils.llms import get_llm as get_llm_via_openworm_ai
|
|
| 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 |
|
| 15 |
|
| 16 |
from openworm_ai.utils.llms import LLM_GPT35
|
|
@@ -84,27 +85,6 @@ def get_llm(llm_ver, temperature):
|
|
| 84 |
return llm
|
| 85 |
|
| 86 |
|
| 87 |
-
def generate_response(input_text, llm_ver, temperature, only_celegans):
|
| 88 |
-
print("---- Gen response to: [%s] for [%s]" % (input_text, llm_ver))
|
| 89 |
-
template = (
|
| 90 |
-
GENERAL_QUERY_LIMITED_PROMPT_TEMPLATE
|
| 91 |
-
if only_celegans
|
| 92 |
-
else GENERAL_QUERY_PROMPT_TEMPLATE
|
| 93 |
-
)
|
| 94 |
-
prompt = PromptTemplate(template=template, input_variables=["question"])
|
| 95 |
-
|
| 96 |
-
try:
|
| 97 |
-
llm = get_llm(llm_ver, temperature)
|
| 98 |
-
|
| 99 |
-
llm_chain = prompt | llm | StrOutputParser()
|
| 100 |
-
|
| 101 |
-
response = llm_chain.invoke(input_text)
|
| 102 |
-
except Exception as e:
|
| 103 |
-
return "Error when processing that request:\n\n%s" % (e)
|
| 104 |
-
|
| 105 |
-
return response
|
| 106 |
-
|
| 107 |
-
|
| 108 |
def generate_panel_response(input_text, llm_panelists, llm_panel_chair, temperature):
|
| 109 |
responses = {}
|
| 110 |
|
|
|
|
| 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
|
|
|
|
| 85 |
return llm
|
| 86 |
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
def generate_panel_response(input_text, llm_panelists, llm_panel_chair, temperature):
|
| 89 |
responses = {}
|
| 90 |
|