-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappp.py
More file actions
33 lines (31 loc) · 1.25 KB
/
appp.py
File metadata and controls
33 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import google.genai as gai
from google.genai.types import Part, GenerateContentConfig
import os
from dotenv import load_dotenv
load_dotenv()
if os.getenv("GOOGLE_API_KEY") is None or os.getenv("GOOGLE_API_KEY") == "":
print("GOOGLE_API_KEY is not set")
raise ValueError("GOOGLE_API_KEY not found in environment variables.")
client = gai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
model_id = "gemini-2.5-flash"
prompt="""Provide an accurate summary of the video. Focus on the concepts being discussed and provide detailed background about the content and topic of the video. Add any additional context for topics being discussed. Do not add commentary of your own."""
generate_content_config = GenerateContentConfig(
temperature = 0.7,
top_p = 0.7,
max_output_tokens = 8192,
response_modalities = ["TEXT"],
)
def generate(youtube_url:str, additional_prompt:str):
response = client.models.generate_content(
model=model_id,
contents=[
Part.from_uri(
file_uri=youtube_url,
mime_type="video/*",
),
Part.from_text(text=prompt+additional_prompt),
],
config = generate_content_config,
)
print(response.text)
return response.text