Spaces:
Build error
Build error
Commit ·
82f5d7f
1
Parent(s): 4628266
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,14 +20,24 @@ def setup_openai(api_key):
|
|
| 20 |
openai.api_key = api_key
|
| 21 |
return "API Key Set Successfully!"
|
| 22 |
|
| 23 |
-
def
|
| 24 |
-
return "You pressed the button!"
|
| 25 |
-
|
| 26 |
-
def ask_joe(api_key, text, btn_press):
|
| 27 |
global conversation_history
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# set up the api_key
|
| 33 |
setup_openai(api_key)
|
|
@@ -62,15 +72,12 @@ def ask_joe(api_key, text, btn_press):
|
|
| 62 |
|
| 63 |
return model_message
|
| 64 |
|
| 65 |
-
button = gr.Button("Press Me")
|
| 66 |
-
button.click(on_button_click, outputs="text")
|
| 67 |
-
|
| 68 |
iface = gr.Interface(
|
| 69 |
fn=ask_joe,
|
| 70 |
inputs=[
|
| 71 |
gr.inputs.Textbox(label="OpenAI API Key"),
|
| 72 |
gr.inputs.Textbox(label="Enter your question here. More detail = Better results"),
|
| 73 |
-
|
| 74 |
],
|
| 75 |
outputs=gr.outputs.Textbox(label="Joe's Response")
|
| 76 |
)
|
|
|
|
| 20 |
openai.api_key = api_key
|
| 21 |
return "API Key Set Successfully!"
|
| 22 |
|
| 23 |
+
def ask_joe(api_key, text, clear):
|
|
|
|
|
|
|
|
|
|
| 24 |
global conversation_history
|
| 25 |
+
if clear:
|
| 26 |
+
# Reset the conversation history
|
| 27 |
+
conversation_history = [
|
| 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)
|
|
|
|
| 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.Checkbox(label="Clear Conversation")
|
| 81 |
],
|
| 82 |
outputs=gr.outputs.Textbox(label="Joe's Response")
|
| 83 |
)
|