Spaces:
Build error
Build error
Commit
•
91b6eab
1
Parent(s):
44c92af
Update app.py
Browse files
app.py
CHANGED
@@ -20,25 +20,11 @@ def setup_openai(api_key):
|
|
20 |
openai.api_key = api_key
|
21 |
return "API Key Set Successfully!"
|
22 |
|
23 |
-
def ask_joe(api_key, text,
|
24 |
-
|
25 |
-
if
|
26 |
-
|
27 |
-
|
28 |
-
{
|
29 |
-
"role": "system",
|
30 |
-
"content": "Your name is Joe Chip, a world-class poker player..."
|
31 |
-
"If you need more context ask for it."
|
32 |
-
"Make sure you know the effective stack and whether its a cash game or mtt. Ask for clarification if not sure"
|
33 |
-
"Concentrate more on GTO play rather than exploiting other players."
|
34 |
-
"Consider blockers when applicable"
|
35 |
-
"Always discuss how to play your range, not just the hand in question"
|
36 |
-
"Remember to keep your answers short and succinct"
|
37 |
-
"Only answer questions on poker topics"
|
38 |
-
}
|
39 |
-
]
|
40 |
-
return "Conversation cleared."
|
41 |
-
|
42 |
# set up the api_key
|
43 |
setup_openai(api_key)
|
44 |
|
@@ -72,14 +58,15 @@ def ask_joe(api_key, text, clear):
|
|
72 |
|
73 |
return model_message
|
74 |
|
|
|
75 |
iface = gr.Interface(
|
76 |
fn=ask_joe,
|
77 |
inputs=[
|
78 |
gr.inputs.Textbox(label="OpenAI API Key"),
|
79 |
gr.inputs.Textbox(label="Enter your question here. More detail = Better results"),
|
80 |
-
gr.inputs.
|
81 |
],
|
82 |
-
outputs=gr.outputs.Textbox(label="Joe's Response")
|
83 |
)
|
84 |
|
85 |
iface.launch()
|
|
|
20 |
openai.api_key = api_key
|
21 |
return "API Key Set Successfully!"
|
22 |
|
23 |
+
def ask_joe(api_key, text, btn_clear):
|
24 |
+
# If button clicked, clear the conversation
|
25 |
+
if btn_clear:
|
26 |
+
conversation_history.clear()
|
27 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
# set up the api_key
|
29 |
setup_openai(api_key)
|
30 |
|
|
|
58 |
|
59 |
return model_message
|
60 |
|
61 |
+
|
62 |
iface = gr.Interface(
|
63 |
fn=ask_joe,
|
64 |
inputs=[
|
65 |
gr.inputs.Textbox(label="OpenAI API Key"),
|
66 |
gr.inputs.Textbox(label="Enter your question here. More detail = Better results"),
|
67 |
+
gr.inputs.Button(label="Clear Conversation") # Button to clear the conversation
|
68 |
],
|
69 |
+
outputs=gr.outputs.Textbox(label="Joe's Response"),
|
70 |
)
|
71 |
|
72 |
iface.launch()
|