Jiaaaaaaax commited on
Commit
25c6871
·
verified ·
1 Parent(s): 312e0bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -16,6 +16,24 @@ from pyannote.audio import Pipeline
16
  import time
17
  import ffmpeg
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  # MediaProcessor class handles media processing (transcription and diarization)
20
  class MediaProcessor:
21
  def __init__(self, auth_token: str):
@@ -136,6 +154,7 @@ class MITIAnalyzer:
136
  def __init__(self, api_key):
137
  # Set the API key for Google Gemini
138
  genai.configure(api_key=api_key)
 
139
  self.global_scores = {
140
  "cultivating_change": None,
141
  "softening_sustain-talk": None,
@@ -154,6 +173,9 @@ class MITIAnalyzer:
154
  "emphasize": 0, # Emphasizing Autonomy
155
  "confront": 0
156
  }
 
 
 
157
 
158
  def extract_score(self, response_text):
159
  """Extract numerical score from Gemini API response"""
@@ -176,7 +198,7 @@ class MITIAnalyzer:
176
  model = genai.GenerativeModel('gemini-1.5-flash')
177
  generation_config = genai.GenerationConfig(max_output_tokens=2048)
178
  for dimension in self.global_scores.keys():
179
- prompt = self.load_prompt(f"Motivational-Interviewing/prompts/prompts/0{list(self.global_scores.keys()).index(dimension)+1}-MITI-global-{dimension.replace('_', '-')}.md")
180
 
181
  full_prompt = f"{prompt}\n\n<transcript>\n{transcript_df.to_csv(index=False)}\n</transcript>"
182
 
 
16
  import time
17
  import ffmpeg
18
 
19
+ # Configuration Management
20
+ class Config:
21
+ GEMINI_MODEL = "gemini-1.5-flash"
22
+ GEMINI_TEMPERATURE = 0.1
23
+ BATCH_SIZE = 5
24
+ RATE_LIMIT_DELAY = 6 # seconds between API calls
25
+
26
+ # Logging configuration
27
+ LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
28
+ LOG_LEVEL = logging.INFO
29
+
30
+ # Initialize logging
31
+ logging.basicConfig(
32
+ level=Config.LOG_LEVEL,
33
+ format=Config.LOG_FORMAT
34
+ )
35
+
36
+
37
  # MediaProcessor class handles media processing (transcription and diarization)
38
  class MediaProcessor:
39
  def __init__(self, auth_token: str):
 
154
  def __init__(self, api_key):
155
  # Set the API key for Google Gemini
156
  genai.configure(api_key=api_key)
157
+ self.model = genai.GenerativeModel('gemini-1.5-flash')
158
  self.global_scores = {
159
  "cultivating_change": None,
160
  "softening_sustain-talk": None,
 
173
  "emphasize": 0, # Emphasizing Autonomy
174
  "confront": 0
175
  }
176
+ logging.info("MITIAnalyzer initialized successfully")
177
+
178
+
179
 
180
  def extract_score(self, response_text):
181
  """Extract numerical score from Gemini API response"""
 
198
  model = genai.GenerativeModel('gemini-1.5-flash')
199
  generation_config = genai.GenerationConfig(max_output_tokens=2048)
200
  for dimension in self.global_scores.keys():
201
+ prompt = self.load_prompt(f"MEXA-tranquil-turing/Motivational-Interviewing/prompts/prompts/0{list(self.global_scores.keys()).index(dimension)+1}-MITI-global-{dimension.replace('_', '-')}.md")
202
 
203
  full_prompt = f"{prompt}\n\n<transcript>\n{transcript_df.to_csv(index=False)}\n</transcript>"
204