PRIYANSHUDHAKED's picture
Update qa_engine.py
c7ba6ae verified
raw
history blame contribute delete
784 Bytes
import google.generativeai as genai
import os
# Configure the Gemini API
import os
import google.generativeai as genai
os.environ["GOOGLE_API_KEY"] = "AIzaSyD0GxR2J1JxGic807Cc89Jq6MB4aDJYgDc"
genai.configure()
# Initialize the Gemini Pro model for text-based tasks
model = genai.GenerativeModel('gemini-1.5-flash')
def get_answer(question, video_data):
prompt = f"""
Based on the following video information, please answer the question.
Video Summary: {video_data['summary']}
Extracted Text: {video_data['extracted_text']}
Transcription: {video_data['transcription']}
Extracted Code: {video_data['extracted_code']}
Question: {question}
Answer:
"""
response = model.generate_content(prompt)
return response.text