Skip to content

Commit

Permalink
Merge pull request #11 from NREL/debug_cox
Browse files Browse the repository at this point in the history
debug_cox
  • Loading branch information
grantbuster authored Dec 14, 2023
2 parents f05e0fc + a6d7386 commit 323066e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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'?")
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

0 comments on commit 323066e

Please sign in to comment.