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