From 835f6cb67cb048d1e16b81e0e1f764c6a5a9566b Mon Sep 17 00:00:00 2001 From: Ashish Mahendra Date: Mon, 28 Oct 2024 14:12:23 +0000 Subject: [PATCH] Update import statements --- app/app.py | 2 +- app/src/app.jac | 17 ++++++++-------- .../components/auto_evaluator/auto_eval.jac | 5 +++-- .../auto_evaluator/emb_sim_scorer.impl.jac | 20 +++++++++---------- .../auto_evaluator/emb_sim_scorer.jac | 2 +- .../auto_evaluator/llm_as_evaluator.impl.jac | 3 ++- .../components/dashboard/dashboard.impl.jac | 4 ++-- .../components/dashboard/model_ranking.jac | 2 +- app/src/components/dashboard/plot_utils.jac | 2 +- .../components/generator/generator.impl.jac | 2 +- .../components/human_eval/human_eval.impl.jac | 3 ++- app/src/components/setup/setup.jac | 2 +- app/src/components/theme.jac | 2 +- app/src/components/utils.jac | 2 +- app/src/tests/test_llm_as_evaluator.jac | 2 +- app/src/tests/test_login.jac | 5 ++--- app/src/tests/test_setup.jac | 4 ++-- 17 files changed, 40 insertions(+), 39 deletions(-) diff --git a/app/app.py b/app/app.py index 6764f18..61944a2 100644 --- a/app/app.py +++ b/app/app.py @@ -2,5 +2,5 @@ import streamlit as st st.set_page_config(page_title="SLaM Tool", page_icon=":robot_face:", layout="wide") -st_app = jac_import("app", base_path="src") +(st_app,) = jac_import("app", base_path="src") st_app.main() diff --git a/app/src/app.jac b/app/src/app.jac index bc5ebb1..bc6b7ef 100644 --- a/app/src/app.jac +++ b/app/src/app.jac @@ -1,14 +1,13 @@ '''SLaM Tool.''' import:py streamlit as st; - -import:jac from components.about, about; -import:jac from components.auto_evaluator.auto_eval, auto_eval; -import:jac from components.dashboard.dashboard, dashboard; -import:jac from components.generator.generator, generator; -import:jac from components.human_eval.human_eval, human_eval; -import:jac from components.login, login; -import:jac from components.setup.setup, setup; -import:jac from components.theme, footer; +import from components.about {about} +import from components.auto_eval {auto_eval} +import from components.dashboard.dashboard {dashboard} +import from components.generator.generator {generator} +import from components.human_eval.human_eval {human_eval} +import from components.login {login} +import from components.setup.setup {setup} +import from components.theme {footer} '''Main function for the SLaM Tool.''' can main { diff --git a/app/src/components/auto_evaluator/auto_eval.jac b/app/src/components/auto_evaluator/auto_eval.jac index ed23341..bc7adb1 100644 --- a/app/src/components/auto_evaluator/auto_eval.jac +++ b/app/src/components/auto_evaluator/auto_eval.jac @@ -1,7 +1,8 @@ '''Auto Evaluator.''' import:py streamlit as st; -import:jac from emb_sim_scorer, emb_sim_scorer; -import:jac from llm_as_evaluator, llm_as_evaluator; +import from emb_sim_scorer {emb_sim_scorer} +import from llm_as_evaluator {llm_as_evaluator} + '''Auto Evaluator Window.''' can auto_eval { diff --git a/app/src/components/auto_evaluator/emb_sim_scorer.impl.jac b/app/src/components/auto_evaluator/emb_sim_scorer.impl.jac index c2a9e21..880a473 100644 --- a/app/src/components/auto_evaluator/emb_sim_scorer.impl.jac +++ b/app/src/components/auto_evaluator/emb_sim_scorer.impl.jac @@ -2,18 +2,18 @@ import:py streamlit as st; import:py os; import:py json; import:py time; -import:py from sklearn.metrics.pairwise, cosine_similarity; +import from sklearn.metrics.pairwise {cosine_similarity} import:py numpy as np; -import:jac from ..dashboard.dashboard, heat_map; -import:py from pathlib, Path; -import:py from sentence_transformers, SentenceTransformer; -import:py from nltk.tokenize, word_tokenize; -import:py from nltk.translate.bleu_score, sentence_bleu; -import:py from nltk.translate.bleu_score, SmoothingFunction; -import:py from torch, tensor; -import:py from nltk, ngrams; +import from ..dashboard.dashboard {heat_map} +import from pathlib {Path} +import from sentence_transformers {SentenceTransformer} +import from nltk.tokenize {word_tokenize} +import from nltk.translate.bleu_score {sentence_bleu} +import from nltk.translate.bleu_score {SmoothingFunction} +import from torch {tensor} +import from nltk {ngrams} import:py tensorflow as tf; -import:py from collections, Counter; +import from collections {Counter} :can:generate_embeddings(anchor_responses_text: list, response_texts: list, embedder: str) { diff --git a/app/src/components/auto_evaluator/emb_sim_scorer.jac b/app/src/components/auto_evaluator/emb_sim_scorer.jac index 5f21116..92bf7f1 100644 --- a/app/src/components/auto_evaluator/emb_sim_scorer.jac +++ b/app/src/components/auto_evaluator/emb_sim_scorer.jac @@ -1,5 +1,5 @@ import:py streamlit as st; -import:py from sentence_transformers, SentenceTransformer; +import from sentence_transformers {SentenceTransformer} can generate_embeddings(anchor_responses_text: str, response_texts: list, embedder: str); can calculate_similarity_score(anchor_embeddings: list, response_embeddings: list, scorer: str); diff --git a/app/src/components/auto_evaluator/llm_as_evaluator.impl.jac b/app/src/components/auto_evaluator/llm_as_evaluator.impl.jac index f12b1b5..86458fb 100644 --- a/app/src/components/auto_evaluator/llm_as_evaluator.impl.jac +++ b/app/src/components/auto_evaluator/llm_as_evaluator.impl.jac @@ -5,7 +5,8 @@ import:py re; import:py streamlit as st; import:py time; -import:jac from ..utils, llms, check_engine_status, load_engine, run_inference; +import from ..utils {llms, check_engine_status, load_engine, run_inference} + :can:llm_as_evaluator { st.title("LLM as an Evaluator"); diff --git a/app/src/components/dashboard/dashboard.impl.jac b/app/src/components/dashboard/dashboard.impl.jac index 1f54bac..3a92df8 100644 --- a/app/src/components/dashboard/dashboard.impl.jac +++ b/app/src/components/dashboard/dashboard.impl.jac @@ -8,9 +8,9 @@ import:py plotly.figure_factory as ff; import:py shutil; import:py streamlit as st; import:py zipfile; +import from ..utils {map_prompt_names_to_ids, generate_performance_data, format_responses_by_prompt} +import from .plot_utils {generate_stacked_bar_chart, generate_heatmaps} -import:jac from ..utils, map_prompt_names_to_ids, generate_performance_data, format_responses_by_prompt; -import:jac from plot_utils, generate_stacked_bar_chart, generate_heatmaps; :can:<>init { diff --git a/app/src/components/dashboard/model_ranking.jac b/app/src/components/dashboard/model_ranking.jac index 1279dc3..08cb2d2 100644 --- a/app/src/components/dashboard/model_ranking.jac +++ b/app/src/components/dashboard/model_ranking.jac @@ -1,6 +1,6 @@ import:py pandas as pd; import:py streamlit as st; -import:jac from utils, map_prompt_names_to_ids, format_responses_by_prompt; +import from utils {map_prompt_names_to_ids, format_responses_by_prompt} can model_win_percentage_table { if st.session_state.get("current_hv_config", None) { diff --git a/app/src/components/dashboard/plot_utils.jac b/app/src/components/dashboard/plot_utils.jac index c1ee1f7..d609d7e 100644 --- a/app/src/components/dashboard/plot_utils.jac +++ b/app/src/components/dashboard/plot_utils.jac @@ -2,7 +2,7 @@ import:py streamlit as st; import:py os; import:py pandas as pd; import:py numpy as np; -import:py from plotly.subplots, make_subplots; +import from plotly.subplots {make_subplots} import:py plotly.graph_objects as go; import:py json; diff --git a/app/src/components/generator/generator.impl.jac b/app/src/components/generator/generator.impl.jac index edd7ac5..c7c5a99 100644 --- a/app/src/components/generator/generator.impl.jac +++ b/app/src/components/generator/generator.impl.jac @@ -3,8 +3,8 @@ import:py streamlit as st; import:py re; import:py uuid; import:py json; +import from ..utils {load_engine, run_inference, llms, check_query_engine, check_ollama_server, convert_run, check_engine_status} -import:jac from ..utils, load_engine, run_inference, llms, check_query_engine, check_ollama_server, convert_run, check_engine_status; :can:<>init { os.makedirs('runs', exist_ok=True); diff --git a/app/src/components/human_eval/human_eval.impl.jac b/app/src/components/human_eval/human_eval.impl.jac index 96e96af..16978f4 100644 --- a/app/src/components/human_eval/human_eval.impl.jac +++ b/app/src/components/human_eval/human_eval.impl.jac @@ -5,7 +5,8 @@ import:py time; import:py streamlit as st; import:py string; import:py random; -import:py from captcha.image, ImageCaptcha; +import from captcha.image {ImageCaptcha} + :can:<>init { if os.path.exists(os.path.join(".human_eval_config", "config.json")) { diff --git a/app/src/components/setup/setup.jac b/app/src/components/setup/setup.jac index d7e13ff..724e544 100644 --- a/app/src/components/setup/setup.jac +++ b/app/src/components/setup/setup.jac @@ -1,5 +1,5 @@ '''Evaluation Setup''' -import:py from datetime, datetime; +import from datetime {datetime} import:py json; import:py os; import:py shutil; diff --git a/app/src/components/theme.jac b/app/src/components/theme.jac index 1dba143..2c21b03 100644 --- a/app/src/components/theme.jac +++ b/app/src/components/theme.jac @@ -1,6 +1,6 @@ '''Theme Utils for Streamlit''' import:py os; -import:py from PIL, Image; +import from PIL {Image} import:py streamlit as st; '''Load custom CSS for Streamlit app''' diff --git a/app/src/components/utils.jac b/app/src/components/utils.jac index aeb24ef..c174383 100644 --- a/app/src/components/utils.jac +++ b/app/src/components/utils.jac @@ -4,7 +4,7 @@ import:py os; import:py shutil; import:py time; import:py streamlit as st; -import:py from datetime, datetime; +import from datetime {datetime} glob ACTION_SERVER_URL: str=os.environ.get("ACTION_SERVER_URL", "http://localhost:8000"); glob OLLAMA_SERVER_URL: str=os.environ.get("OLLAMA_SERVER_URL", "http://localhost:11434"); diff --git a/app/src/tests/test_llm_as_evaluator.jac b/app/src/tests/test_llm_as_evaluator.jac index 3d3608c..bfa5c9a 100644 --- a/app/src/tests/test_llm_as_evaluator.jac +++ b/app/src/tests/test_llm_as_evaluator.jac @@ -4,7 +4,7 @@ import:py time; import:py shutil; import:py requests; import:py subprocess; -import:jac from helpers, get_item_by_label; +import from helpers {get_item_by_label} test app_running { :g: app; diff --git a/app/src/tests/test_login.jac b/app/src/tests/test_login.jac index 654978f..f5b3ac6 100644 --- a/app/src/tests/test_login.jac +++ b/app/src/tests/test_login.jac @@ -1,7 +1,6 @@ -import:py from streamlit.testing.v1, AppTest; +import from streamlit.testing.v1 {AppTest} import:py os; - -import:jac from helpers, get_item_by_label; +import from helpers {get_item_by_label} test app_running { :g: app; diff --git a/app/src/tests/test_setup.jac b/app/src/tests/test_setup.jac index 2402775..a1a4eb7 100644 --- a/app/src/tests/test_setup.jac +++ b/app/src/tests/test_setup.jac @@ -1,9 +1,9 @@ import:py json; import:py os; import:py shutil; -import:py from streamlit.testing.v1, AppTest; +import from streamlit.testing.v1 {AppTest} -import:jac from helpers, get_item_by_label; +import from helpers {get_item_by_label} test app_running {