rithvick commited on
Commit
cd763ab
·
verified ·
1 Parent(s): 5244b29

fixed major changes

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -7,12 +7,31 @@ from google.cloud import aiplatform
7
  from transformers import pipeline
8
  from google.genai import types
9
  import gradio as gr
10
- apikey = "AIzaSyCeY0ji2gnMwvP8jGCU_Z5DG6m9Ybo3JeE" # Replace or use os.getenv if secret
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # Configure Gemini API for drafting (free)
13
  genai_ext.configure(api_key=apikey)
14
- llm_model = genai_ext.GenerativeModel('gemini-1.5-flash')
15
-
16
  # Real classifiers
17
  emotion_classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base") # For D
18
  sentiment_classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") # For M
@@ -61,7 +80,7 @@ class HumanLikeChatbot:
61
  # Clean input
62
  clean_message = message.lower().strip()
63
  if len(clean_message) < 3 or not any(c.isalpha() for c in clean_message):
64
- return "Bhai, yeh kya likha? Clear bol na, main samajh lunga! (E Score: 0.0)"
65
 
66
  # Emotion detect from tuned model
67
  contents = [
 
7
  from transformers import pipeline
8
  from google.genai import types
9
  import gradio as gr
10
+ import torch
11
+ import os, tempfile
12
+ import json
13
+
14
+ creds_json = os.getenv("GCP_CREDS_JSON")
15
+ if not creds_json:
16
+ raise Exception("⚠️ Missing GCP_CREDS_JSON secret!")
17
+
18
+ # Save to temp file
19
+ with tempfile.NamedTemporaryFile(mode='w+', delete=False) as tmpfile:
20
+ tmpfile.write(creds_json)
21
+ creds_path = tmpfile.name
22
+
23
+ os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = creds_path
24
+
25
+ # Initialize GCP API
26
+ aiplatform.init(project="your-project-id", location="us-central1")
27
+
28
+
29
+
30
+ apikey = os.environ["GEMINI_API_KEY"] # Replace or use os.getenv if secret
31
 
32
  # Configure Gemini API for drafting (free)
33
  genai_ext.configure(api_key=apikey)
34
+ llm_model = genai_ext.GenerativeModel('gemini-1.5-pro')
 
35
  # Real classifiers
36
  emotion_classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base") # For D
37
  sentiment_classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") # For M
 
80
  # Clean input
81
  clean_message = message.lower().strip()
82
  if len(clean_message) < 3 or not any(c.isalpha() for c in clean_message):
83
+ return "Be clear buddy (E Score: 0.0)"
84
 
85
  # Emotion detect from tuned model
86
  contents = [