Skip to content

Commit

Permalink
added option to energy wizard to return openai chat object instead of…
Browse files Browse the repository at this point in the history
… text
  • Loading branch information
grantbuster committed Nov 2, 2023
1 parent c7026b1 commit 39eed1d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion elm/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def chat(self, query,
convo=False,
token_budget=None,
new_info_threshold=0.7,
print_references=False):
print_references=False,
return_chat_obj=False):
"""Answers a query by doing a semantic search of relevant text with
embeddings and then sending engineered query to the LLM.
Expand Down Expand Up @@ -248,6 +249,8 @@ def chat(self, query,
print_references : bool
Flag to print references if EnergyWizard is initialized with a
valid ref_col.
return_chat_obj : bool
Flag to only return the ChatCompletion from OpenAI API.
Returns
-------
Expand Down Expand Up @@ -279,6 +282,9 @@ def chat(self, query,

response = openai.ChatCompletion.create(**kwargs)

if return_chat_obj:
return response, query, references

if stream:
for chunk in response:
chunk_msg = chunk['choices'][0]['delta']
Expand Down

0 comments on commit 39eed1d

Please sign in to comment.