Skip to content

Commit

Permalink
fix some functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed Oct 23, 2024
1 parent d5e9d84 commit 721245f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion alphastats/gui/pages/04_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def show_start_llm_button(method: str) -> None:

msg = (
"(this will overwrite the existing LLM analysis!)"
if StateKeys.LLM_INTEGRATION in st.session_state
if st.session_state.get(StateKeys.LLM_INTEGRATION, {}) != {}
else ""
)

Expand Down
9 changes: 4 additions & 5 deletions alphastats/gui/pages/05_LLM.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ def llm_config():
api_key=st.session_state[StateKeys.OPENAI_API_KEY],
base_url=base_url,
)
st.success(
f"Connection to {api_type} successful!"
) if error is None else st.error(
f"❌ Connection to {api_type} failed: {error}"
)
if error is None:
st.success(f"Connection to {api_type} successful!")
else:
st.error(f"❌ Connection to {api_type} failed: {str(error)}")

if model_before != st.session_state[StateKeys.API_TYPE]:
st.rerun(scope="app")
Expand Down
4 changes: 3 additions & 1 deletion alphastats/gui/utils/llm_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def llm_connection_test(
) -> Optional[str]:
"""Test the connection to the LLM API, return None in case of success, error message otherwise."""
try:
llm = LLMIntegration(api_type, base_url=base_url, api_key=api_key)
llm = LLMIntegration(
api_type, base_url=base_url, api_key=api_key, load_tools=False
)
llm.chat_completion("Hello there!")
return None

Expand Down
6 changes: 3 additions & 3 deletions alphastats/llm/llm_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(
base_url: Optional[str] = None,
api_key: Optional[str] = None,
system_message: str = None,
load_tools: bool = True,
dataset: Optional[DataSet] = None,
gene_to_prot_id_map: Optional[Dict[str, str]] = None,
):
Expand All @@ -77,12 +78,11 @@ def __init__(
self._metadata = None if dataset is None else dataset.metadata
self._gene_to_prot_id_map = gene_to_prot_id_map

self._tools = self._get_tools()
self._tools = self._get_tools() if load_tools else None

self._artifacts = {}
self._messages = [] # the conversation history used for the LLM, could be truncated at some point.
self._all_messages = [] # full conversation history for display
self._artifacts = {}

if system_message is not None:
self._append_message("system", system_message)

Expand Down

0 comments on commit 721245f

Please sign in to comment.