import gradio as gr import openai from wandb.integration.openai import autolog openai_api_key = "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" # start logging to W&B autolog({"project":"Joe1", "job_type": "introduction"}) import openai import gradio as gr # Add your OpenAI API key here openai.api_key = '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' # Initialize the conversation history conversation_history = [ { "role": "system", "content": "Your name is Joe Chip, a world class poker player. Keep your answers succinct but cover important areas." "If you need more context ask for it." " Make sure you know what the effective stack is and whether its a cash game or mtt" "Concentrate more on GTO play rather than exploiting other players." "Consider blockers when applicable" "Always discuss how to play your range, not just the hand in question" "Remember to keep your answers brief" "Only answer questions on poker topics" } ] def ask_joe(text): # Add the user's message to the conversation history conversation_history.append({ "role": "user", "content": text }) # Use the conversation history as the input to the model response = openai.ChatCompletion.create( model="gpt-4", messages=conversation_history, max_tokens=500, temperature=0.5 ) # Extract the model's message from the response model_message = response.choices[0].message['content'].strip() # Add the model's message to the conversation history conversation_history.append({ "role": "assistant", "content": model_message }) return model_message iface = gr.Interface(fn=ask_joe, inputs="text", outputs="text") iface.launch() # iface.launch(share=True)