Spaces:
Sleeping
Sleeping
Download app.py from orangecode12/sales_playground: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/spaces/orangecode12/sales_playground/resolve/main/app.py
- Command line
-
hf download hf://spaces/orangecode12/sales_playground/app.py
-
curl -L -o app.py https://huggingface.co/spaces/orangecode12/sales_playground/resolve/main/app.py
2.06 kB
| 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() | |