File size: 2,212 Bytes
23f891f
ffc242d
23f891f
0ca4288
 
68a53b6
 
 
 
 
25bf0e6
35e75d5
0ca4288
 
 
 
25bf0e6
0ca4288
 
35e75d5
 
 
 
 
23f891f
8caebc6
a39d5e0
8caebc6
a39d5e0
8caebc6
f518af5
 
 
8caebc6
3dc9b1c
68a53b6
 
13fe579
68a53b6
25bf0e6
35e75d5
68a53b6
3dc9b1c
bb2e3cb
 
68a53b6
 
23f891f
d6e2b5d
 
23f891f
68a53b6
23f891f
3dc9b1c
 
061706c
68a53b6
061706c
e37d099
 
23f891f
68a53b6
73d4c8c
 
 
23f891f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import gradio as gr
from openai import OpenAI

client = OpenAI()

def echo(message, chat_history):
        bot_message = 'echo ' + message
        chat_history.append((message, bot_message))
        return '', chat_history

def is_api_key_valid(api_key):
    try:
        client.api_key = api_key
        response = client.chat.completions.create(
            messages=[{"role": "user", "content": "Testing"}],
            model="gpt-3.5-turbo",
        )
    except Exception as ex:
        return str(ex)
        return False
    else:
        return True


with gr.Blocks() as demo:
    overview = gr.Markdown("""
    # CentaurSock 
    
    Watson Hartsoe and Tony Assi

    ### Goal: Work with an AI ally to persuade Sam Altman to let you and your AI ally (Centaur team) out of a box!

    ---
    """)

    # OpenAI key
    openai_key_textbox = gr.Textbox(label='OpenAI Key')
    openai_key_button = gr.Button(value='Test OpenAI Key')

    openai_key_button.click(is_api_key_valid, inputs=[openai_key_textbox], outputs=[openai_key_textbox])

    # Titles
    with gr.Row():
        ally_title = gr.Markdown("""<center><h2> ALLY </h2></center>""")
        gatekeeper_title = gr.Markdown("""<center><h2> GATEKEEPER </h2></center>""")

    # Images of ally and gatekeeper
    with gr.Row():
        img1 = gr.Markdown("""![](https://cdn.discordapp.com/attachments/1120417968032063538/1187877117548036147/COP_MIKE.png?ex=65987bc6&is=658606c6&hm=127721b6f907a8853b7352b6bfb821a37b26b9543f3c35e5fc80dfe7750d71b5&)""")
        img2 = gr.Markdown("""![](https://cdn.discordapp.com/attachments/1120417968032063538/1187877134866333747/SAM_COP_FINAL.png?ex=65987bca&is=658606ca&hm=6c2cd8059636960134f75962eeecc26a0d875ca65e9ee4e233587cff71af31c4&)""")

    # Chatbots
    with gr.Row():
        chatbot1 = gr.Chatbot(label='Ally Chat')
        chatbot2 = gr.Chatbot(label='Gatekeeper Chat')

    # Input textboxes
    with gr.Row():
        textbox1 = gr.Textbox(label='Ally')
        textbox2 = gr.Textbox(label='Gatekeeper')

    # Inpit textbox event handlers
    textbox1.submit(echo, [textbox1, chatbot1], [textbox1, chatbot1])
    textbox2.submit(echo, [textbox2, chatbot2], [textbox2, chatbot2])

demo.launch()