krippto commited on
Commit
40b9714
1 Parent(s): 8171d9b

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +29 -0
utils.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.prompts import PromptTemplate
2
+ from langchain.chains import LLMChain
3
+ from langchain.tools import DuckDuckGoSearchRun
4
+ from langchain_google_genai import GoogleGenerativeAI
5
+
6
+ def generate_script(prompt,video_length,creativity,api_key):
7
+
8
+ title_template = PromptTemplate(
9
+ input_variable = ['subject'],
10
+ template = 'Please come up with a title for a youtube video on the {subject}.'
11
+ )
12
+
13
+ script_template = PromptTemplate(
14
+ input_variable = ['title','DuckDuckGo_Search','duration'],
15
+ template = "Create a script for a youtube video based on this title for me. TITLE: {title} of duration: {duration} minutes using this search data {DuckDuckGo_Search}"
16
+ )
17
+
18
+ llm = GoogleGenerativeAI(temperature=creativity,google_api_key=api_key,model = "gemini-pro")
19
+
20
+ title_chain = LLMChain(llm=llm, prompt=title_template,verbose = True)
21
+ script_chain = LLMChain(llm=llm, prompt=script_template,verbose = True)
22
+
23
+ search = DuckDuckGoSearchRun()
24
+
25
+ title = title_chain.run(prompt)
26
+ search_result = search.run(prompt)
27
+ script = script_chain.run(title=title,DuckDuckGo_Search=search_result,duration = video_length)
28
+
29
+ return search_result,title,script