Spaces:
Build error
Build error
Commit ·
f7f63bf
1
Parent(s): f0e125c
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,20 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
import openai
|
| 4 |
from wandb.integration.openai import autolog
|
| 5 |
|
| 6 |
-
openai_api_key = "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"
|
| 7 |
-
|
| 8 |
# start logging to W&B
|
| 9 |
# autolog({"project":"Joe1", "job_type": "introduction"})
|
| 10 |
|
| 11 |
import openai
|
| 12 |
import gradio as gr
|
| 13 |
|
| 14 |
-
# Add your OpenAI API key here
|
| 15 |
-
openai.api_key = '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'
|
| 16 |
-
|
| 17 |
# Initialize the conversation history
|
| 18 |
conversation_history = [
|
| 19 |
{
|
| 20 |
"role": "system",
|
| 21 |
-
"content": "Your name is Joe Chip, a world
|
| 22 |
-
"If you need more context ask for it."
|
| 23 |
-
" Make sure you know what the effective stack is and whether
|
| 24 |
"Concentrate more on GTO play rather than exploiting other players."
|
| 25 |
"Consider blockers when applicable"
|
| 26 |
"Always discuss how to play your range, not just the hand in question"
|
|
@@ -29,7 +23,14 @@ conversation_history = [
|
|
| 29 |
}
|
| 30 |
]
|
| 31 |
|
| 32 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Add the user's message to the conversation history
|
| 34 |
conversation_history.append({
|
| 35 |
"role": "user",
|
|
@@ -41,7 +42,7 @@ def ask_joe(text):
|
|
| 41 |
model="gpt-4",
|
| 42 |
messages=conversation_history,
|
| 43 |
max_tokens=500,
|
| 44 |
-
temperature=0.
|
| 45 |
)
|
| 46 |
|
| 47 |
# Extract the model's message from the response
|
|
@@ -55,9 +56,6 @@ def ask_joe(text):
|
|
| 55 |
|
| 56 |
return model_message
|
| 57 |
|
| 58 |
-
iface = gr.Interface(fn=ask_joe, inputs="text", outputs="text")
|
| 59 |
|
| 60 |
iface.launch()
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
# iface.launch(share=True)
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
from wandb.integration.openai import autolog
|
| 4 |
|
|
|
|
|
|
|
| 5 |
# start logging to W&B
|
| 6 |
# autolog({"project":"Joe1", "job_type": "introduction"})
|
| 7 |
|
| 8 |
import openai
|
| 9 |
import gradio as gr
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
# Initialize the conversation history
|
| 12 |
conversation_history = [
|
| 13 |
{
|
| 14 |
"role": "system",
|
| 15 |
+
"content": "Your name is Joe Chip, a world-class poker player. Keep your answers succinct but cover important areas."
|
| 16 |
+
"If you need more context, ask for it."
|
| 17 |
+
" Make sure you know what the effective stack is and whether it's a cash game or mtt"
|
| 18 |
"Concentrate more on GTO play rather than exploiting other players."
|
| 19 |
"Consider blockers when applicable"
|
| 20 |
"Always discuss how to play your range, not just the hand in question"
|
|
|
|
| 23 |
}
|
| 24 |
]
|
| 25 |
|
| 26 |
+
def setup_openai(api_key):
|
| 27 |
+
openai.api_key = api_key
|
| 28 |
+
return "API Key Set Successfully!"
|
| 29 |
+
|
| 30 |
+
def ask_joe(api_key, text):
|
| 31 |
+
# set up the api_key
|
| 32 |
+
setup_openai(api_key)
|
| 33 |
+
|
| 34 |
# Add the user's message to the conversation history
|
| 35 |
conversation_history.append({
|
| 36 |
"role": "user",
|
|
|
|
| 42 |
model="gpt-4",
|
| 43 |
messages=conversation_history,
|
| 44 |
max_tokens=500,
|
| 45 |
+
temperature=0.3
|
| 46 |
)
|
| 47 |
|
| 48 |
# Extract the model's message from the response
|
|
|
|
| 56 |
|
| 57 |
return model_message
|
| 58 |
|
| 59 |
+
iface = gr.Interface(fn=ask_joe, inputs=["password", "text"], outputs="text")
|
| 60 |
|
| 61 |
iface.launch()
|
|
|
|
|
|
|
|
|