Spaces:
Sleeping
Sleeping
Update tweet_analyzer.py
Browse files- tweet_analyzer.py +26 -13
tweet_analyzer.py
CHANGED
@@ -109,22 +109,33 @@ class TweetDatasetProcessor:
|
|
109 |
|
110 |
def generate_tweet(self, context=""):
|
111 |
"""Generate a new tweet based on personality profile and optional context"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
generation_prompt = f"""Based on this personality profile:
|
113 |
{self.personality_profile}
|
114 |
-
|
115 |
Current context or topic (if any):
|
116 |
{context}
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
"""
|
127 |
-
|
128 |
response = self.groq_client.chat.completions.create(
|
129 |
messages=[
|
130 |
{
|
@@ -137,6 +148,8 @@ class TweetDatasetProcessor:
|
|
137 |
}
|
138 |
],
|
139 |
model="mixtral-8x7b-32768",
|
140 |
-
temperature=0.
|
|
|
141 |
)
|
142 |
-
|
|
|
|
109 |
|
110 |
def generate_tweet(self, context=""):
|
111 |
"""Generate a new tweet based on personality profile and optional context"""
|
112 |
+
additional_contexts = [
|
113 |
+
"Comment on a recent technological advancement.",
|
114 |
+
"Share a motivational thought.",
|
115 |
+
"Discuss a current trending topic.",
|
116 |
+
"Reflect on a past experience.",
|
117 |
+
"Provide advice to followers."
|
118 |
+
]
|
119 |
+
|
120 |
+
# Randomly choose an additional context to diversify tweets
|
121 |
+
import random
|
122 |
+
random_context = random.choice(additional_contexts)
|
123 |
+
|
124 |
generation_prompt = f"""Based on this personality profile:
|
125 |
{self.personality_profile}
|
|
|
126 |
Current context or topic (if any):
|
127 |
{context}
|
128 |
+
Additionally, consider this specific context:
|
129 |
+
{random_context}
|
130 |
+
Generate a tweet that this person would write right now. Consider:
|
131 |
+
1. Their core beliefs and values
|
132 |
+
2. Their typical emotional expression
|
133 |
+
3. Their communication style and vocabulary
|
134 |
+
4. Their knowledge areas and experiences
|
135 |
+
5. Current context (if provided)
|
136 |
+
The tweet should feel indistinguishable from their authentic tweets.
|
137 |
"""
|
138 |
+
|
139 |
response = self.groq_client.chat.completions.create(
|
140 |
messages=[
|
141 |
{
|
|
|
148 |
}
|
149 |
],
|
150 |
model="mixtral-8x7b-32768",
|
151 |
+
temperature=0.8, # Increase temperature for more diversity
|
152 |
+
max_tokens=150, # Adjust max tokens for more substantial tweets
|
153 |
)
|
154 |
+
|
155 |
+
return response.choices[0].message.content
|