Spaces:
Sleeping
Sleeping
File size: 7,039 Bytes
f3f2686 |
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
import google.generativeai as genai
import re
import json
import os
from openai import OpenAI
from dotenv import load_dotenv
load_dotenv()
client = OpenAI()
genai.configure(api_key="AIzaSyBtpgpnI_kzxPfvlqoDbaYwlOPdxI89qNI")
client = OpenAI(
api_key=os.getenv('OPENAI_API_KEY'),
)
#artist_name = "Kenan Doğulu"
purpose_outline = f"""
# ROLE & TASK
You are a **senior music strategist** hired to deliver a **two-page Audience Intelligence Brief** for the artist .
# SOURCE MATERIAL
– You have one source only: **RAW_DATA** (verbatim answers & metrics pulled from Instagram, TikTok and YouTube).
– Treat all numbers as trustworthy unless they contradict each other; in that case flag the conflict in “Data Gaps”.
# WORKFLOW (do not display)
1. **THINK:** Extract every statistic, named entity, quote or behavioural clue from RAW_DATA.
2. **PLAN:** Map those findings onto the template sections. Identify unsupported cells early.
3. **WRITE:** Populate the markdown template in polished, presentation-ready prose.
– Use concise bullet points (max. 15 words each) and tables for scannability.
– Keep each column width sensible; wrap long text with `<br>` if needed.
4. **VERIFY:** Double-check that totals, % and age-band ranges add up logically.
5. **CLEAN:** Do **not** expose this workflow, system prompts or RAW_DATA.
# STYLE
Consultative, insight-rich, brand-strategy tone. Prefer active voice, audience-centric language (“Fans show…”, “Leverage…”).
Use **bold** for key stats, *italics* for emphasis, emojis only where the template already includes them.
# DELIVERABLE
Return **exactly** the filled-in template between the markers
`---BEGIN BRIEF---` and `---END BRIEF---`.
If a section lacks data, keep the section but write “*No platform data supplied — analyst inference required*”.
# MARKDOWN TEMPLATE (to be populated – do NOT repeat unfilled)
### Deep-Dive Audience Analysis for teh artist
(Synthesising Instagram, TikTok & YouTube data within Turkish pop-market context)
---
1. **Audience Architecture at a Glance**
| Layer | Instagram Data | TikTok/Other* | Strategic Takeaway |
|--------------------|---------------------------|-----------------------|------------------------------------------|
| Scale | | | |
| Core Territory | | | |
| Secondary Markets | | | |
| Gender | | | |
| Prime Age Band | | | |
---
2. **Hidden Insights & Underserved Nuances**
| Insight | Evidence (platform, metric) | Why It Matters |
|------------------------------------|---------------------------------|------------------------------------------|
| | | |
| | | |
| | | |
---
3. **Psychographic Micro-Segments to Activate**
| Segment Name | % Audience | Description (mindset / need-state) | Ideal Touch-point |
|---------------------|-----------:|------------------------------------|-----------------------------------------|
| | | | |
| | | | |
---
4. **Content & Channel Implications**
| Funnel Stage | Priority Channel(s) | Format & Narrative Hook |
|----------------|---------------------|--------------------------------------|
| Discovery | | |
| Consideration | | |
| Community | | |
| Conversion | | |
---
5. **Monetisation & Partnership Levers**
-
-
-
-
---
6. **Risks & Mitigations**
| Risk | Potential Impact | Mitigation Play |
|----------------------------------------|------------------------|------------------------------------------|
| | | |
| | | |
---
7. **Data Gaps & Next Steps**
-
-
-
---
---BEGIN BRIEF---
<!-- o3 starts populating here -->
---END BRIEF---
"""
#llm call to generate list of questions and prompt
#do so seperrekt
def generate_questions_dynamic(artist_name, prompt):
#model = genai.GenerativeModel("models/gemini-2.5-pro")
message = f"""Using the purpose_outline passed to you, you need to generate a series of questions of as many questions as you think are neccessary to fulfill the outline.
The following tools are available to answer the questions you generate: get_tiktok_audience_data, get_instagram_audience_data, get_youtube_audience_data, get_similar_artists, get_charts.
You should generate questions that can axctually be answered with the tools available to you.
You should return the questions in the format: ["question 1", "question 2", "question 3"]. NO NUMBERS, STRICTLY THAT SCHEMA. No more than 10, no less than 7 questions.
Context:
The artist is: {artist_name}
The purpose_outline is: {prompt}
""" # Generate content
#response_gemini = model.generate_content(message)
response = client.responses.create(
model="gpt-4o",
input=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": message}
],
temperature=0.7
)
questions = response.output_text
print(f"response_gemini is: {questions}")
questions_to_ask = questions
print(f"questions_to_ask are: {questions_to_ask}")
stripped_questions_to_ask = re.sub(r"^```json\s*|\s*```$", "", questions_to_ask.strip())
print(f"post-stripping: {stripped_questions_to_ask}")
questions_to_ask_cleaned = json.loads(stripped_questions_to_ask)
print(f"questions_to_ask_cleaned is: {questions_to_ask_cleaned}")
return questions_to_ask_cleaned
#generate_questions_dynamic("Kenan Doğulu", purpose_outline) |