PRIYANSHUDHAKED commited on
Commit
5cff4fd
·
verified ·
1 Parent(s): 6ef8dec

Create qa_engine.py

Browse files
Files changed (1) hide show
  1. qa_engine.py +25 -0
qa_engine.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import google.generativeai as genai
2
+ import os
3
+
4
+ # Configure the Gemini API
5
+ genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
6
+
7
+ # Initialize the Gemini Pro model for text-based tasks
8
+ model = genai.GenerativeModel('gemini-pro')
9
+
10
+ def get_answer(question, video_data):
11
+ prompt = f"""
12
+ Based on the following video information, please answer the question.
13
+
14
+ Video Summary: {video_data['summary']}
15
+ Extracted Text: {video_data['extracted_text']}
16
+ Transcription: {video_data['transcription']}
17
+ Extracted Code: {video_data['extracted_code']}
18
+
19
+ Question: {question}
20
+
21
+ Answer:
22
+ """
23
+
24
+ response = model.generate_content(prompt)
25
+ return response.text