Mummia-99 commited on
Commit
ee82d09
·
verified ·
1 Parent(s): 69a7ed1

Upload video_script_app.py

Browse files
Files changed (1) hide show
  1. video_script_app.py +27 -0
video_script_app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import openai
3
+
4
+
5
+ openai.api_key = "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"
6
+
7
+ def generate_video_script(blog_post):
8
+ messages = [
9
+ {"role": "system", "content": "You are a video script generator. Create engaging and concise video scripts from blog posts."},
10
+ {"role": "user", "content": f"Create a video script from the following blog post:\n{blog_post}"}
11
+ ]
12
+ try:
13
+ response = openai.chat.completions.create(
14
+ model="gpt-3.5-turbo", # Or another suitable chat model
15
+ messages=messages,
16
+ max_tokens=500
17
+ )
18
+ return response.choices[0].message.content.strip()
19
+ except openai.OpenAIError as e:
20
+ return f"An error occurred: {e}"
21
+
22
+ st.title("Video Script Generator")
23
+ blog_post = st.text_area("Enter Blog Post:")
24
+ if st.button("Submit"):
25
+ if blog_post:
26
+ script = generate_video_script(blog_post)
27
+ st.write(script)