afia1naseem2 commited on
Commit
aef5261
·
verified ·
1 Parent(s): c9bc07c

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -190
app.py DELETED
@@ -1,190 +0,0 @@
1
- import gradio as gr
2
- import re
3
- import time
4
- from dotenv import load_dotenv
5
- import os
6
- from openai import OpenAI
7
-
8
- # 🔐 Load API Key from .env
9
- load_dotenv()
10
- api_key = os.getenv("OPENAI_API_KEY")
11
- client = OpenAI(api_key=api_key)
12
-
13
-
14
- def extract_keywords(paragraph):
15
- prompt = f"""
16
- You are an expert in experiential event planning.
17
-
18
- Extract 5-0 short, specific, and thematic keywords or concepts from the event description below. These will be used to inspire immersive, tech-powered event ideas.
19
-
20
- Each keyword should be 2-4 words long and describe a concrete idea or theme (e.g., "AR photo booths", "smart vending", "interactive storytelling").
21
-
22
- Event Description:
23
- "{paragraph}"
24
-
25
- Return the keywords as a comma-separated list.
26
- """
27
- response = client.chat.completions.create(
28
- model="gpt-4",
29
- messages=[{"role": "user", "content": prompt}],
30
- temperature=0.7,
31
- max_tokens=200
32
- )
33
-
34
- keywords_raw = response.choices[0].message.content
35
- keywords = re.split(r'[,\n]', keywords_raw)
36
- return [kw.strip() for kw in keywords if kw.strip()]
37
-
38
-
39
- def extract_keywords_from_title_and_link(title, link):
40
- prompt = f"""
41
- You are an expert in event innovation.
42
-
43
- Given the title and link below, extract 3–5 short, specific, and meaningful keywords or themes (2–4 words each) that describe what the page is about.
44
-
45
- Title: {title}
46
- Link: {link}
47
-
48
- Return the keywords as a comma-separated list.
49
- """
50
- response = client.chat.completions.create(
51
- model="gpt-4",
52
- messages=[{"role": "user", "content": prompt}],
53
- temperature=0.6,
54
- max_tokens=150
55
- )
56
-
57
- raw = response.choices[0].message.content
58
- return [kw.strip() for kw in re.split(r'[,\n]', raw) if kw.strip()]
59
-
60
-
61
- def search_similar_events_and_products_openai(keywords):
62
- input_text = f"Generate 10 useful URLs for experiential event ideas or iBoothMe.com inspiration related to the keywords: {', '.join(keywords)}"
63
-
64
- try:
65
- print("🌐 Using OpenAI web search tool...")
66
- response = client.responses.create(
67
- model="gpt-4.1",
68
- tools=[{"type": "web_search_preview"}],
69
- input=input_text
70
- )
71
- content = response.output_text
72
- results = []
73
- for line in content.strip().split("\n"):
74
- if "http" in line:
75
- parts = line.split(" - ", 1)
76
- if len(parts) == 2:
77
- results.append((parts[0].strip(), parts[1].strip()))
78
- else:
79
- url = line.strip()
80
- results.append((url, url))
81
- return results[:10]
82
- except Exception as e:
83
- print(f"Search failed: {e}")
84
- return []
85
-
86
-
87
- def generate_event_ideas(paragraph, search_links):
88
- search_summary = "\n".join([f"- {title}: {url}" for title, url in search_links])
89
-
90
- prompt = f"""
91
- You are an expert event strategist for iBoothMe, a company offering creative experiences like AI photo booths, smart vending machines, audio booths, personalization stations, and immersive visual storytelling.
92
-
93
- Based on the event description below, generate 6-7 **unique and diverse** iBoothMe-powered event ideas.
94
-
95
- **Event Description:**
96
- {paragraph}
97
-
98
- **Inspiration from Related Ideas:**
99
- {search_summary}
100
-
101
- 💡 **Your Task:**
102
- Create ideas that are immersive, memorable, and creatively use iBoothMe's **photo, video, and audio**-based technologies. Do **not** use AR, VR, projection mapping, or other tech-heavy elements.
103
-
104
- You can optionally include:
105
- - Studio Ghibli-inspired visuals **(in just one idea)**
106
- - Personalized giveaways (e.g., Labibu dolls, custom t-shirts, stickers)
107
- - Audio booths, video diaries, face filters, sound remixes, or creative vending
108
-
109
- ❗ Important:
110
- - Avoid using AR, VR, holograms, or projection domes
111
- - Don’t repeat formats like photo booths
112
- - Every idea should have a **creative title** and a **detailed explanation** of how iBoothMe enhances the experience
113
-
114
- Return only the final ideas in markdown format.
115
- """
116
- response = client.chat.completions.create(
117
- model="gpt-4",
118
- messages=[{"role": "user", "content": prompt}],
119
- temperature=0.95,
120
- max_tokens=1000
121
- )
122
-
123
- return response.choices[0].message.content
124
-
125
-
126
- def main_workflow(paragraph):
127
- print("🚀 Started workflow")
128
-
129
- if not paragraph.strip():
130
- return "❌ Please enter an event description."
131
-
132
- print("🔍 Extracting keywords from paragraph...")
133
- base_keywords = extract_keywords(paragraph)
134
-
135
- print("🌐 Searching using OpenAI tool...")
136
- links = search_similar_events_and_products_openai(base_keywords)
137
-
138
- print("🔍 Extracting extra keywords from titles and links...")
139
- link_keywords = []
140
- for title, url in links:
141
- link_keywords.extend(extract_keywords_from_title_and_link(title, url))
142
-
143
- all_keywords = sorted(set(base_keywords + link_keywords))
144
-
145
- print("🧠 Generating ideas...")
146
- ideas = generate_event_ideas(paragraph, links)
147
-
148
- keyword_summaries = []
149
- for kw in all_keywords[:10]:
150
- try:
151
- response = client.chat.completions.create(
152
- model="gpt-4",
153
- messages=[{"role": "user", "content": f"Give a short one-line event idea description using the keyword: {kw}"}],
154
- temperature=0.6,
155
- max_tokens=60
156
- )
157
- description = response.choices[0].message.content.strip()
158
- keyword_summaries.append(f"- **{kw.title()}**: {description}")
159
- except:
160
- keyword_summaries.append(f"- **{kw.title()}**")
161
-
162
- formatted_links = "\n".join(keyword_summaries)
163
-
164
- return f"""
165
-
166
- 🌐 **Relevant Ideas:**
167
- {formatted_links}
168
-
169
- 💡 **Event Concepts Based on iBoothMe:**
170
- {ideas}
171
- """
172
-
173
-
174
- # 🎨 Gradio UI
175
- with gr.Blocks(title="iBoothMe Event Ideation App") as demo:
176
- gr.Markdown("## 🎉 iBoothMe Event Idea Generator\nDescribe your event goal and receive 6–7 interactive, tech-powered ideas!")
177
-
178
- paragraph = gr.Textbox(label="📝 Describe Your Event (e.g. Women's Day, Product Launch)", lines=4)
179
-
180
- submit_btn = gr.Button("🚀 Generate Event Concepts")
181
- output = gr.Markdown()
182
-
183
- submit_btn.click(
184
- fn=main_workflow,
185
- inputs=[paragraph],
186
- outputs=output,
187
- show_progress=True
188
- )
189
-
190
- demo.launch(inline=False,share=True)