File size: 2,063 Bytes
5246f29
 
 
 
 
 
 
1bc0a5f
cd560f6
 
 
 
8e87eb2
 
5246f29
8e87eb2
 
 
 
 
 
 
 
5246f29
 
 
 
a9e9acc
fc9d9be
5246f29
 
 
8e87eb2
 
5246f29
 
 
a006a2f
cd560f6
5246f29
 
c2efe09
 
 
 
 
 
 
 
 
 
 
 
 
cd560f6
5246f29
 
8e87eb2
 
 
cd560f6
8e87eb2
 
5246f29
 
 
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
67
import os
import gradio as gr
import requests

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
PLAYGROUND_TOKEN = os.getenv("PLAYGROUND_TOKEN", "changeme")

def call_gpt(token, master_prompt, checklist, transcript):
    # Simple auth check
    if token != PLAYGROUND_TOKEN:
        return "❌ Unauthorized. Wrong token."
        
    # Combine inputs dynamically
    full_prompt = f"""{master_prompt}

Checklist:
{checklist}

Transcript:
{transcript}
"""

    # --- Your GPT API call logic ---
    resp = requests.post(
        "https://api.openai.com/v1/chat/completions",
        headers={"Authorization": f"Bearer {OPENAI_API_KEY}"},
        json={
            "model": "gpt-5",
            "messages": [{"role": "user", "content": full_prompt}]
        },
    )
    if resp.status_code != 200:
        return f"Error: {resp.text}"
    return resp.json()["choices"][0]["message"]["content"]

# Gradio UI
with gr.Blocks() as demo:
    gr.Markdown("# Sales Playground")
    token_box = gr.Textbox(lines=1, label="Token")
    check_list_box = gr.Textbox(lines=5, label="Checklist")
    transcript_box = gr.Textbox(lines=5, label="Transcript")
    master_prompt_box = gr.Textbox(
    lines=8,
    label="Prompt",
    value="""Analyze the manager's behavior according to the provided checklist, using only the content of the meeting transcript. Respond with brief but extreamly informative report.

# Output Format
Your response should be a brief (up to 10 sentences) analysis in Russian, structured in bullet points, clearly referencing both the transcript and checklist points as appropriate.
Use one of informative emojis at the beginnind of each bullet: 
✅ Criteria is met
⚠️ Criteria is partially met
❌ Criteria is not met"""
)

    output_box = gr.Textbox(lines=10, label="Report")
    submit = gr.Button("Send")

    # Pass the *components*, not strings
    submit.click(
        fn=call_gpt,
        inputs=[token_box, master_prompt_box, check_list_box, transcript_box],
        outputs=output_box,
    )

if __name__ == "__main__":
    demo.launch()