Update app.py
Browse files
app.py
CHANGED
@@ -30,7 +30,7 @@ def get_redirected_url_video_id(mobile_url):
|
|
30 |
chrome_options.add_argument("--disable-gpu")
|
31 |
|
32 |
# Specify the path to the ChromeDriver executable
|
33 |
-
chrome_driver_path = '
|
34 |
|
35 |
# Create a new Chrome session
|
36 |
service = Service(chrome_driver_path)
|
@@ -109,25 +109,24 @@ def generate_story(comments, temperature=0.7):
|
|
109 |
comments_text = " ".join(words)
|
110 |
|
111 |
openai.api_key = OPENAI_API_KEY
|
112 |
-
|
|
|
113 |
model="gpt-3.5-turbo",
|
114 |
-
messages=[
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
)
|
130 |
-
return completion.choices[0].message['content']
|
131 |
|
132 |
# Main function to execute the process
|
133 |
def main(youtube_url, temperature):
|
|
|
30 |
chrome_options.add_argument("--disable-gpu")
|
31 |
|
32 |
# Specify the path to the ChromeDriver executable
|
33 |
+
chrome_driver_path = 'chromedriver' # Update this path
|
34 |
|
35 |
# Create a new Chrome session
|
36 |
service = Service(chrome_driver_path)
|
|
|
109 |
comments_text = " ".join(words)
|
110 |
|
111 |
openai.api_key = OPENAI_API_KEY
|
112 |
+
client = openai
|
113 |
+
completion = client.chat.completions.create(
|
114 |
model="gpt-3.5-turbo",
|
115 |
+
messages=[{"role": "system", "content": f"""
|
116 |
+
|
117 |
+
Read all the comments, understand the emotions people are feeling and pick any random emotion
|
118 |
+
and create a story in first person (the person can be randomly young or old and the story can be
|
119 |
+
based in past or future) based on that emotion picking a random character keep the words
|
120 |
+
simple and a bit profound but overall simple words. Give more weight to the comments that
|
121 |
+
come earlier in sequence. The comments are given here: {comments_text}"""},
|
122 |
+
{"role": "assistant", "content": """
|
123 |
+
ignore the comment which has lyrics of the song,
|
124 |
+
ignore all comments similar to 'anyone in 2024', Keep the story randomly between 50-120 words.
|
125 |
+
dont mention the emtion chosen just start the story.
|
126 |
+
sometimes include bits where you tell how this song makes you feel. be very nostalgic about a feeling or a place this
|
127 |
+
takes you to. half the times end the story with a hopeful future or a dark end or humorous.. choose randomly"""}]
|
128 |
+
,temperature=temperature)
|
129 |
+
return completion.choices[0].message.content
|
|
|
|
|
130 |
|
131 |
# Main function to execute the process
|
132 |
def main(youtube_url, temperature):
|