Skip to content

Commit

Permalink
Update import statements
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishMahendra committed Oct 28, 2024
1 parent 74d9da5 commit 835f6cb
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
17 changes: 8 additions & 9 deletions app/src/app.jac
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions app/src/components/auto_evaluator/auto_eval.jac
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions app/src/components/auto_evaluator/emb_sim_scorer.impl.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/auto_evaluator/emb_sim_scorer.jac
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/auto_evaluator/llm_as_evaluator.impl.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/dashboard/dashboard.impl.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/dashboard/model_ranking.jac
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/dashboard/plot_utils.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion app/src/components/generator/generator.impl.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion app/src/components/human_eval/human_eval.impl.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/setup/setup.jac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''Evaluation Setup'''
import:py from datetime, datetime;
import from datetime {datetime}
import:py json;
import:py os;
import:py shutil;
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/theme.jac
Original file line number Diff line number Diff line change
@@ -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'''
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/utils.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion app/src/tests/test_llm_as_evaluator.jac
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions app/src/tests/test_login.jac
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions app/src/tests/test_setup.jac
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 835f6cb

Please sign in to comment.