Skip to content

Commit

Permalink
fixed the query_engine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chandralegend committed Mar 25, 2024
1 parent 7fffd52 commit 10b874f
Show file tree
Hide file tree
Showing 31 changed files with 748 additions and 839 deletions.
12 changes: 5 additions & 7 deletions scripts/backup.jac
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@ import:py zipfile;
import:py datetime;

glob current_time = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S');

glob GDRIVE_FOLDER_ID = os.environ['GDRIVE_FOLDER_ID'];

can zipdir(folders:list[str], out:str) {
can zipdir(folders: list[str], out: str) {
with zipfile.ZipFile(out, 'w', zipfile.ZIP_DEFLATED) as zipf {
for folder in folders {
for (root, _, files) in os.walk(folder) {
for file in files {
zipf.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file),
os.path.join(folder, '..')));
zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), os.path.join(folder, '..')));
}
}
}
}
}

can upload_file_to_drive(file: str, folder_id: str) {
file_drive = drive.CreateFile({'parents': [{'id': folder_id}]});
file_drive = drive.CreateFile({'parents':[{'id':folder_id }] });
file_drive.SetContentFile(file);
file_drive.Upload();
}
Expand All @@ -31,8 +30,7 @@ with entry {
gauth = GoogleAuth();
gauth.LocalWebserverAuth();
drive = GoogleDrive(gauth);

zipdir([".human_eval_config", "results", "data"], f"{current_time}.zip");
upload_file_to_drive(f"{current_time}.zip", GDRIVE_FOLDER_ID);
os.remove(f"{current_time}.zip");
}
}
21 changes: 7 additions & 14 deletions scripts/runs2data.jac
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,39 @@ import:py os;
import:py argparse;

can convert_run(run: str, prompt_disc: str) {
responses_files = [f for f in os.listdir(os.path.join("runs", run)) if f.endswith(".json")];
data = {
"run": run,
"prompt_disc": prompt_disc,
"outputs": {}
};

responses_files = [f for f in os.listdir(os.path.join("runs", run)) if f.endswith(".json")];
data = {"run":run, "prompt_disc":prompt_disc, "outputs":{} };

for responses_file in responses_files {
with open(os.path.join("runs", run, responses_file), "r") as f {
model_data = json.load(f);
model_name = model_data["model_name"];
prompt = model_data["full_prompt"];
responses = [r["response"] for r in model_data["outputs"]];
responses = [r["response"] for r in model_data["outputs"]];
data["outputs"][model_name] = responses;
data["prompt"] = prompt if "prompt" not in data else data["prompt"];
}
}

with open(os.path.join("data", f"{run}_responses"), "w") as f {
json.dump(data, f, indent=4);
}
}


with entry {
parser = argparse.ArgumentParser(description="Convert the runs to data");
parser.add_argument("-r", "--run_name", default="all", help="The run to convert");
args = parser.parse_args();

os.makedirs("data", exist_ok=True);
runs = [f for f in os.listdir("runs") if os.path.isdir(os.path.join("runs", f))];
runs = [f for f in os.listdir("runs") if os.path.isdir(os.path.join("runs", f))];
if args.run == "all" {
for run in runs {
prompt_disc_md = input(f"Provide the relative path to the prompt description markdown (.md) for run");
prompt_disc = open(prompt_disc_md, "r").read();
convert_run(run, prompt_disc);
}
} else {
} else {
prompt_disc_md = input(f"Provide the relative path to the prompt description markdown (.md) for run");
prompt_disc = open(prompt_disc_md, "r").read();
convert_run(args.run, prompt_disc);
}
}
}
39 changes: 26 additions & 13 deletions src/app.jac
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import:py streamlit as st;

import:jac from components.utils, login;
import:jac from components.generator, generator;
import:jac from components.setup, setup;
Expand All @@ -10,20 +9,34 @@ import:jac from components.about, about;
import:jac from components.theme, footer;

can main {
if "admin_privileges" not in st.session_state {st.session_state.admin_privileges = False;}
if "admin_privileges" not in st.session_state {
st.session_state.admin_privileges = False;
}
(human_eval_tab, admin_tab) = st.tabs(["Human Evaluation", "Admin Panel"]);
with human_eval_tab {human_eval();}
with human_eval_tab {
human_eval();
}
with admin_tab {
if not st.session_state.admin_privileges {login();}
else {
(dashboard_tab, generator_tab, evaluation_tab, setup_tab, about_tab) = st.tabs(["Dashboard",
"Response Generator", "Auto Evaluator", "Human Eval Setup", "About"]);
with dashboard_tab {dashboard();}
with generator_tab {generator();}
with evaluation_tab { auto_eval();}
with setup_tab {setup();}
with about_tab {about();}
if not st.session_state.admin_privileges {
login();
} else {
(dashboard_tab, generator_tab, evaluation_tab, setup_tab, about_tab) = st.tabs(["Dashboard", "Response Generator", "Auto Evaluator", "Human Eval Setup", "About"]);
with dashboard_tab {
dashboard();
}
with generator_tab {
generator();
}
with evaluation_tab {
auto_eval();
}
with setup_tab {
setup();
}
with about_tab {
about();
}
}
}
footer();
}
}
2 changes: 1 addition & 1 deletion src/components/about.jac
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ can about {
st.markdown(citation);
st.header("Contacts");
st.markdown(socials_mk);
}
}
17 changes: 11 additions & 6 deletions src/components/auto_eval.jac
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import:py streamlit as st;

import:jac from emb_sim_scorer, emb_sim_scorer;
import:jac from model_ranking, model_win_percentage_table;
import:jac from llm_as_evaluator, llm_as_evaluator;

can auto_eval {
(gpt_evaluator, sim_scorer_tab,model_ranking) = st.tabs(["LLM as Evaluator", "Similarity Scorer", "Model Ranking"]);
with sim_scorer_tab {emb_sim_scorer();}
with model_ranking {model_win_percentage_table();}
with gpt_evaluator {llm_as_evaluator();}
}
(gpt_evaluator, sim_scorer_tab, model_ranking) = st.tabs(["LLM as Evaluator", "Similarity Scorer", "Model Ranking"]);
with sim_scorer_tab {
emb_sim_scorer();
}
with model_ranking {
model_win_percentage_table();
}
with gpt_evaluator {
llm_as_evaluator();
}
}
Loading

0 comments on commit 10b874f

Please sign in to comment.