Spaces:
Runtime error
Runtime error
Commit
·
b976780
1
Parent(s):
76e72f0
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def get_api_key():
|
|
21 |
return api_key
|
22 |
|
23 |
def respond(message, chat_history):
|
24 |
-
|
25 |
# Get embeddings
|
26 |
embeddings = OpenAIEmbeddings()
|
27 |
|
@@ -33,6 +33,8 @@ def respond(message, chat_history):
|
|
33 |
"maximal_marginal_relevance":True,
|
34 |
"k":10})
|
35 |
|
|
|
|
|
36 |
# Create ChatOpenAI and ConversationalRetrievalChain
|
37 |
model = ChatOpenAI(model='gpt-3.5-turbo')
|
38 |
qa = ConversationalRetrievalChain.from_llm(model, retriever)
|
@@ -40,7 +42,7 @@ def respond(message, chat_history):
|
|
40 |
bot_message = qa({"question": message, "chat_history": chat_history})
|
41 |
chat_history = [(message, bot_message["answer"])]
|
42 |
time.sleep(1)
|
43 |
-
return chat_history
|
44 |
|
45 |
with gr.Blocks() as demo:
|
46 |
with gr.Tab("OpenAI API Key Submission"):
|
@@ -56,7 +58,6 @@ with gr.Blocks() as demo:
|
|
56 |
api_check_button = gr.Button("Get API Key")
|
57 |
api_print = gr.Textbox(label = "OpenAI API Key - Please ensure the API Key is set correctly")
|
58 |
chatbot = gr.Chatbot(label="ChatGPT Powered Coding Assistant")
|
59 |
-
chat_history = []
|
60 |
msg = gr.Textbox(label="User Prompt", placeholder="Your Query Here")
|
61 |
clear = gr.Button("Clear")
|
62 |
|
|
|
21 |
return api_key
|
22 |
|
23 |
def respond(message, chat_history):
|
24 |
+
|
25 |
# Get embeddings
|
26 |
embeddings = OpenAIEmbeddings()
|
27 |
|
|
|
33 |
"maximal_marginal_relevance":True,
|
34 |
"k":10})
|
35 |
|
36 |
+
chat_history = chat_history[1]
|
37 |
+
|
38 |
# Create ChatOpenAI and ConversationalRetrievalChain
|
39 |
model = ChatOpenAI(model='gpt-3.5-turbo')
|
40 |
qa = ConversationalRetrievalChain.from_llm(model, retriever)
|
|
|
42 |
bot_message = qa({"question": message, "chat_history": chat_history})
|
43 |
chat_history = [(message, bot_message["answer"])]
|
44 |
time.sleep(1)
|
45 |
+
return "", chat_history
|
46 |
|
47 |
with gr.Blocks() as demo:
|
48 |
with gr.Tab("OpenAI API Key Submission"):
|
|
|
58 |
api_check_button = gr.Button("Get API Key")
|
59 |
api_print = gr.Textbox(label = "OpenAI API Key - Please ensure the API Key is set correctly")
|
60 |
chatbot = gr.Chatbot(label="ChatGPT Powered Coding Assistant")
|
|
|
61 |
msg = gr.Textbox(label="User Prompt", placeholder="Your Query Here")
|
62 |
clear = gr.Button("Clear")
|
63 |
|