Spaces:
Runtime error
Runtime error
Shaileshshantaram Kadam commited on
Commit ·
313acb9
1
Parent(s): 817481c
Updated app
Browse files- app.py +4 -4
- query_data.py +1 -1
app.py
CHANGED
|
@@ -15,9 +15,9 @@ def set_openai_api_key(api_key: str):
|
|
| 15 |
If no api_key, then None is returned.
|
| 16 |
"""
|
| 17 |
if api_key:
|
| 18 |
-
os.environ["OPENAI_API_KEY"] =
|
| 19 |
chain = get_chain(vectorstore)
|
| 20 |
-
os.environ["OPENAI_API_KEY"] = "
|
| 21 |
return chain
|
| 22 |
|
| 23 |
class ChatWrapper:
|
|
@@ -25,7 +25,7 @@ class ChatWrapper:
|
|
| 25 |
def __init__(self):
|
| 26 |
self.lock = Lock()
|
| 27 |
def __call__(
|
| 28 |
-
self, api_key:
|
| 29 |
):
|
| 30 |
"""Execute the chat functionality."""
|
| 31 |
self.lock.acquire()
|
|
@@ -56,7 +56,7 @@ with block:
|
|
| 56 |
gr.Markdown("<h3><center>Chat-Your-Data (State-of-the-Union)</center></h3>")
|
| 57 |
|
| 58 |
openai_api_key_textbox = gr.Textbox(
|
| 59 |
-
placeholder="sk-
|
| 60 |
show_label=False,
|
| 61 |
lines=1,
|
| 62 |
type="password",
|
|
|
|
| 15 |
If no api_key, then None is returned.
|
| 16 |
"""
|
| 17 |
if api_key:
|
| 18 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
| 19 |
chain = get_chain(vectorstore)
|
| 20 |
+
os.environ["OPENAI_API_KEY"] = ""
|
| 21 |
return chain
|
| 22 |
|
| 23 |
class ChatWrapper:
|
|
|
|
| 25 |
def __init__(self):
|
| 26 |
self.lock = Lock()
|
| 27 |
def __call__(
|
| 28 |
+
self, api_key: str, inp: str, history: Optional[Tuple[str, str]], chain
|
| 29 |
):
|
| 30 |
"""Execute the chat functionality."""
|
| 31 |
self.lock.acquire()
|
|
|
|
| 56 |
gr.Markdown("<h3><center>Chat-Your-Data (State-of-the-Union)</center></h3>")
|
| 57 |
|
| 58 |
openai_api_key_textbox = gr.Textbox(
|
| 59 |
+
placeholder="Paste your OpenAI API key (sk-...)",
|
| 60 |
show_label=False,
|
| 61 |
lines=1,
|
| 62 |
type="password",
|
query_data.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
from langchain.prompts.prompt import PromptTemplate
|
| 2 |
from langchain.llms import OpenAI
|
| 3 |
-
from langchain.chains import
|
| 4 |
|
| 5 |
_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
|
| 6 |
You can assume the question about the most recent state of the union address.
|
|
|
|
| 1 |
from langchain.prompts.prompt import PromptTemplate
|
| 2 |
from langchain.llms import OpenAI
|
| 3 |
+
from langchain.chains import ConversationalRetrievalChain
|
| 4 |
|
| 5 |
_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
|
| 6 |
You can assume the question about the most recent state of the union address.
|