From 75d95339011f2487c2e5397b0e715566eddbb8ed Mon Sep 17 00:00:00 2001 From: steven krawczyk Date: Thu, 10 Aug 2023 10:40:06 -0700 Subject: [PATCH] Revert "Export To MongoDB (#64)" This reverts commit f8bb5c20aeec409807c0e5d3bc14797e727f5637. --- prompttools/playground/data_loader.py | 6 +---- prompttools/playground/playground.py | 38 +++------------------------ 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/prompttools/playground/data_loader.py b/prompttools/playground/data_loader.py index 8e3cb158..3467b4c1 100644 --- a/prompttools/playground/data_loader.py +++ b/prompttools/playground/data_loader.py @@ -57,11 +57,7 @@ def load_data( experiment = EXPERIMENTS[model_type]([model], selectors, temperature=[temperature]) elif model_type == "Anthropic": experiment = EXPERIMENTS[model_type]([model], selectors, temperature=[temperature]) - - try: - return experiment.to_pandas_df(), experiment.to_mongo_db - except Exception as e: - raise Exception(str(e)) + return experiment.to_pandas_df() @st.cache_data diff --git a/prompttools/playground/playground.py b/prompttools/playground/playground.py index 215ce100..2676facc 100644 --- a/prompttools/playground/playground.py +++ b/prompttools/playground/playground.py @@ -177,7 +177,7 @@ link += "&prompt=" + urllib.parse.quote(prompts[0]) if run: - df, to_mongo_db = load_data( + df = load_data( model_type, model, instructions, @@ -190,31 +190,14 @@ api_key, ) st.session_state.df = df - st.session_state.to_mongo_db = to_mongo_db - for i in range(len(prompts)): for j in range(len(instructions)): - placeholders[i][j + 1].markdown(st.session_state.df["response"][i + len(prompts) * j]) - + placeholders[i][j + 1].markdown(df["response"][i + len(prompts) * j]) elif "df" in st.session_state and not clear: df = st.session_state.df for i in range(len(prompts)): for j in range(len(instructions)): placeholders[i][j + 1].markdown(df["response"][i + len(prompts) * j]) - - if "df" in st.session_state and not clear: - st.sidebar.info("Export To MongoDB") - mongo_uri = st.sidebar.text_input("Enter MongoURI") - database = st.sidebar.text_input("Enter Database Name") - collection = st.sidebar.text_input("Enter Collection Name") - export = st.sidebar.button("Export") - loaded = False - if export and mongo_uri and database and collection and export: - with st.sidebar: - with st.spinner("Exporting..."): - st.session_state.to_mongo_db(mongo_uri, database, collection) - st.write("Exported!") - elif mode == "Prompt Template": instruction = None if model_type == "LlamaCpp Chat": @@ -286,31 +269,18 @@ if run: prompts = render_prompts(templates, vars) - df, to_mongo_db = load_data(model_type, model, [instruction], prompts, temperature, api_key) + df = load_data(model_type, model, [instruction], prompts, temperature, api_key) st.session_state.prompts = prompts st.session_state.df = df - st.session_state.to_mongo_db = to_mongo_db for i in range(len(prompts)): for j in range(len(templates)): - placeholders[i][j + variable_count].markdown(st.session_state.df["response"][i + len(prompts) * j]) - + placeholders[i][j + variable_count].markdown(df["response"][i + len(prompts) * j]) elif "df" in st.session_state and "prompts" in st.session_state and not clear: df = st.session_state.df prompts = st.session_state.prompts for i in range(len(prompts)): for j in range(len(templates)): placeholders[i][j + variable_count].markdown(df["response"][i + len(prompts) * j]) - - if "df" in st.session_state and not clear: - st.sidebar.info("Export To MongoDB") - mongo_uri = st.sidebar.text_input("Enter MongoURI") - database = st.sidebar.text_input("Enter Database Name") - collection = st.sidebar.text_input("Enter Collection Name") - export = st.sidebar.button("Export") - if export and mongo_uri and database and collection and export: - st.session_state.to_mongo_db(mongo_uri, database, collection) - - elif mode == "Model Comparison": placeholders = [[st.empty() for _ in range(model_count + 1)] for _ in range(prompt_count)]