Skip to content

Commit

Permalink
Revert "Export To MongoDB (#64)"
Browse files Browse the repository at this point in the history
This reverts commit f8bb5c2.
  • Loading branch information
steventkrawczyk committed Aug 10, 2023
1 parent bbfc550 commit 75d9533
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
6 changes: 1 addition & 5 deletions prompttools/playground/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 4 additions & 34 deletions prompttools/playground/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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":
Expand Down Expand Up @@ -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)]

Expand Down

0 comments on commit 75d9533

Please sign in to comment.