Commit
·
f8e0bc0
1
Parent(s):
abc16ec
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,54 +47,18 @@ class ChatWrapper:
|
|
| 47 |
self.lock.release()
|
| 48 |
return history, history
|
| 49 |
|
| 50 |
-
chat = ChatWrapper()
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 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",
|
| 63 |
-
)
|
| 64 |
|
| 65 |
-
chatbot = gr.Chatbot()
|
| 66 |
-
|
| 67 |
-
with gr.Row():
|
| 68 |
-
message = gr.Textbox(
|
| 69 |
-
label="What's your question?",
|
| 70 |
-
placeholder="Ask questions about the most recent state of the union",
|
| 71 |
-
lines=1,
|
| 72 |
-
)
|
| 73 |
-
submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
|
| 74 |
-
|
| 75 |
-
gr.Examples(
|
| 76 |
-
examples=[
|
| 77 |
-
"What did the president say about Kentaji Brown Jackson",
|
| 78 |
-
"Did he mention Stephen Breyer?",
|
| 79 |
-
"What was his stance on Ukraine",
|
| 80 |
-
],
|
| 81 |
-
inputs=message,
|
| 82 |
-
)
|
| 83 |
-
|
| 84 |
-
gr.HTML("Demo application of a LangChain chain.")
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
state = gr.State()
|
| 88 |
-
agent_state = gr.State()
|
| 89 |
-
|
| 90 |
-
submit.click(chat, inputs=[openai_api_key_textbox, message, state, agent_state], outputs=[chatbot, state],api_name="chat")
|
| 91 |
-
message.submit(chat, inputs=[openai_api_key_textbox, message, state, agent_state], outputs=[chatbot, state])
|
| 92 |
-
|
| 93 |
-
openai_api_key_textbox.change(
|
| 94 |
-
set_openai_api_key,
|
| 95 |
-
inputs=[openai_api_key_textbox],
|
| 96 |
-
outputs=[agent_state],
|
| 97 |
-
)
|
| 98 |
def echo(name, request: gr.Request):
|
| 99 |
if request:
|
| 100 |
print("Request headers dictionary:", request.headers)
|
|
|
|
| 47 |
self.lock.release()
|
| 48 |
return history, history
|
| 49 |
|
|
|
|
| 50 |
|
| 51 |
+
def my_inference_function(name):
|
| 52 |
+
return "Hello " + name + "!"
|
| 53 |
|
| 54 |
+
gradio_interface = gradio.Interface(
|
| 55 |
+
fn = my_inference_function,
|
| 56 |
+
inputs = "text",
|
| 57 |
+
outputs = "text"
|
| 58 |
+
)
|
| 59 |
+
gradio_interface.launch()
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
def echo(name, request: gr.Request):
|
| 63 |
if request:
|
| 64 |
print("Request headers dictionary:", request.headers)
|