Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/anand611_youtube-script-generation.json
T

1 line
3.8 KiB
JSON

{"repo": "anand611/youtube-script-generation", "files": {"utils.py": {"7e15b8494c71e1c5e2bf19b7be5fc78ada1ff9a8": {"t": 1785674526.8052611, "n": 3551, "h": "ac63ba913edd8da3", "c": "#from langchain.llms import OpenAI\n#The above is no longer avialable, so replaced it with the below import :)\n# from langchain_openai import ChatOpenAI\nfrom langchain.chains.llm import LLMChain\nfrom langchain_mistralai.chat_models import ChatMistralAI\nfrom langchain.prompts import PromptTemplate\nfrom langchain.chains import LLMChain\nfrom langchain_community.tools import DuckDuckGoSearchRun\nimport os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-8iW6nev21doh1Lnsfkdh;alfhsFJM2pdNhYz2783g3bO98vjeuPCT\"\nos.environ[\"HUGGINGFACEHUB_API_TOKEN\"] = \"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\"\nos.environ[\"PINECONE_API_KEY\"] = \"pcsk_4kUXTh_Bou27oHeWgQezwntpKBfjaRvNVd6tx8HBMAhieUDBq8ALRMixxA23hrr9cGjDGx\"\nos.environ[\"MISTRAL_API_KEY\"]=\"PzsIjy5b1ldYJEt0thzJPpBGbFKocCFy\"\nos.environ[\"PINECONE_ENV\"]=\"us-east-1\"\nos.environ[\"PINECONE_INDEX\"]=\"ac611\"\n\ndef get_llm_model(index=1):\n models = [\"mistral-large-latest\",\"ministral-3b-latest\"]\n model = ChatMistralAI(model=models[index])\n return model\n\n# Function to generate video script\ndef generate_script(prompt,video_length):\n \n # Template for generating 'Title'\n title_template = PromptTemplate(\n input_variables = ['subject'], \n template='Please come up with a title for a YouTube video on the {subject}.'\n )\n\n # Template for generating 'Video Script' using search engine\n script_template = PromptTemplate(\n input_variables = ['title', 'DuckDuckGo_Search','duration'], \n 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} '\n )\n\n #Setting up OpenAI LLM\n # llm = ChatOpenAI(temperature=creativity,openai_api_key=api_key,\n # model_name='gpt-3.5-turbo') \n llm = get_llm_model()\n \n #Creating chain for 'Title' & 'Video Script'\n title_chain = LLMChain(llm=llm, prompt=title_template, verbose=True)\n script_chain = LLMChain(llm=llm, prompt=script_template, verbose=True)\n\n \n # https://python.langchain.com/docs/modules/agents/tools/integrations/ddg\n search = DuckDuckGoSearchRun()\n\n # Executing the chains we created for 'Title'\n title = title_chain.invoke(prompt)\n\n # Executing the chains we created for 'Video Script' by taking help of search engine 'DuckDuckGo'\n search_result = search.run(prompt) \n script = script_chain.run(title=title, DuckDuckGo_Search=search_result,duration=video_length)\n\n # Returning the output\n return search_result,title,script\n\n\n#################################################################################################################################\n\n\n# import os\n# from langchain_community.document_loaders import PyPDFDirectoryLoader\n# from langchain_mistralai.chat_models import ChatMistralAI\n# from langchain_text_splitters.character import RecursiveCharacterTextSplitter\n# from langchain_huggingface import HuggingFaceEmbeddings\n# from pinecone import Pinecone as PineconeClient\n# from langchain_community.vectorstores import pinecone\n# from langchain.chains.question_answering import load_qa_chain\n# from langchain.output_parsers import StructuredOutputParser,ResponseSchema\n# from langchain.prompts import ChatPromptTemplate,HumanMessagePromptTemplate\n\n# # os.environ[\"OPENAI_API_KEY\"] = \"sk-8iW6nev21doh1Lnsfkdh;alfhsFJM2pdNhYz2783g3bO98vjeuPCT\"\n# # os.environ[\"HUGGINGFACEHUB_API_TOKEN\"] = \"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\"\n# # os.environ[\"PINECONE_API_KEY\"] = \"pcsk_4kUXTh_Bou27oHeWgQezwntpKBfjaRvNVd6tx8HBMAhieUDBq8ALRMixxA23hrr9cGjDGx\"\n\n\n"}}}}