Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

debug_cox #11

Merged
merged 6 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions elm/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, corpus, model=None, token_budget=3500, ref_col=None):
"""

super().__init__(model)

self.corpus = self.preflight_corpus(corpus)
self.token_budget = token_budget
self.embedding_arr = np.vstack(self.corpus['embedding'].values)
Expand Down
2 changes: 1 addition & 1 deletion examples/energy_wizard/retrieve_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# NREL-Azure endpoint. You can also use just the openai endpoint.
# NOTE: embedding values are different between OpenAI and Azure models!
openai.api_base = os.getenv("AZURE_OPENAI_ENDPOINT")
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY")
openai.api_key = os.getenv("AZURE_OPENAI_KEY")
openai.api_type = 'azure'
openai.api_version = '2023-03-15-preview'

Expand Down
12 changes: 11 additions & 1 deletion examples/energy_wizard/run_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import openai
from glob import glob
import pandas as pd
import sys

from elm import EnergyWizard

Expand Down Expand Up @@ -61,7 +62,16 @@ def get_corpus():
@st.cache_resource
def get_wizard():
"""Get the energy wizard object."""
corpus = get_corpus()

# Getting Corpus of data. If no corpus throw error for user.
try:
corpus = get_corpus()
except Exception:
print("Error: Have you run 'retrieve_docs.py'?")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jordantcox alternatives to print() would be raising a custom exception but because this is streamlit weirdness i think this makes sense 👍

st.header("Error")
st.write("Error: Have you run 'retrieve_docs.py'?")
sys.exit(0)

wizard = EnergyWizard(corpus, ref_col='ref', model=model)
return wizard

Expand Down
Loading