Harika22 commited on
Commit
032608d
Β·
verified Β·
1 Parent(s): ecdcd87

Update pages/model.py

Browse files
Files changed (1) hide show
  1. pages/model.py +10 -17
pages/model.py CHANGED
@@ -6,14 +6,9 @@ from youtube_transcript_api import YouTubeTranscriptApi
6
  from langchain_community.document_loaders import YoutubeLoader
7
  from langchain_google_genai import GoogleGenerativeAI,ChatGoogleGenerativeAI
8
 
9
-
10
- hf_token = os.getenv("HF_Token")
11
- if hf_token is None:
12
- st.error("❌ Please set your Hugging Face API token in the environment as 'HF_Token'.")
13
- st.stop()
14
- else:
15
- os.environ["HUGGINGFACEHUB_API_KEY"] = hf_token
16
- os.environ["HF_TOKEN"] = hf_token
17
 
18
  st.set_page_config(page_title="🎬 Tube2Insight", page_icon="πŸŽ₯", layout="wide")
19
 
@@ -56,18 +51,19 @@ if st.button("πŸ” Summarize"):
56
  with st.expander("πŸ“„ View Transcript"):
57
  st.write(transcript)
58
 
59
- llm = ChatHuggingFace(
60
- repo_id="meta-llama/Llama-3.1-8B-Instruct",
61
- model_kwargs={"temperature": 0.5, "max_new_tokens": 300}
 
62
  )
63
-
64
  prompt = ChatPromptTemplate.from_messages([
65
  SystemMessagePromptTemplate.from_template("You are a helpful assistant summarizing YouTube transcripts."),
66
  HumanMessagePromptTemplate.from_template("{transcript}")
67
  ])
68
  messages = prompt.format_messages(transcript=transcript)
69
 
70
- with st.spinner("🧠 Summarizing with LLaMA..."):
71
  response = llm.invoke(messages)
72
 
73
  st.markdown("### πŸ“Œ Summary")
@@ -75,9 +71,6 @@ if st.button("πŸ” Summarize"):
75
 
76
  st.markdown("---")
77
  st.markdown(
78
- "<p style='text-align: center; color: gray;'>πŸš€ Built with LangChain + LLaMA + Streamlit </p>",
79
  unsafe_allow_html=True
80
  )
81
-
82
-
83
-
 
6
  from langchain_community.document_loaders import YoutubeLoader
7
  from langchain_google_genai import GoogleGenerativeAI,ChatGoogleGenerativeAI
8
 
9
+ from google.colab import userdata
10
+ gem=userdata.get('gemini')
11
+ os.environ["GOOGLE_API_KEY"]=gem
 
 
 
 
 
12
 
13
  st.set_page_config(page_title="🎬 Tube2Insight", page_icon="πŸŽ₯", layout="wide")
14
 
 
51
  with st.expander("πŸ“„ View Transcript"):
52
  st.write(transcript)
53
 
54
+ llm = ChatGoogleGenerativeAI(
55
+ model="gemini-2.0-flash",
56
+ temperature=0.5,
57
+ max_output_tokens=512
58
  )
59
+
60
  prompt = ChatPromptTemplate.from_messages([
61
  SystemMessagePromptTemplate.from_template("You are a helpful assistant summarizing YouTube transcripts."),
62
  HumanMessagePromptTemplate.from_template("{transcript}")
63
  ])
64
  messages = prompt.format_messages(transcript=transcript)
65
 
66
+ with st.spinner("🧠 Summarizing with Gemini 2.0 Flash..."):
67
  response = llm.invoke(messages)
68
 
69
  st.markdown("### πŸ“Œ Summary")
 
71
 
72
  st.markdown("---")
73
  st.markdown(
74
+ "<p style='text-align: center; color: gray;'>πŸš€ Built with LangChain + Gemini + Streamlit </p>",
75
  unsafe_allow_html=True
76
  )