Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +58 -11
- me/summary.txt +1 -31
app.py
CHANGED
|
@@ -147,24 +147,71 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
| 147 |
return system_prompt
|
| 148 |
|
| 149 |
def chat(self, message, history):
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
done = False
|
|
|
|
|
|
|
| 154 |
while not done:
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
else:
|
| 164 |
done = True
|
|
|
|
| 165 |
return response.choices[0].message.content
|
| 166 |
|
| 167 |
|
|
|
|
| 168 |
if __name__ == "__main__":
|
| 169 |
me = Me()
|
| 170 |
with gr.Blocks(
|
|
|
|
| 147 |
return system_prompt
|
| 148 |
|
| 149 |
def chat(self, message, history):
|
| 150 |
+
messages = (
|
| 151 |
+
[{"role": "system", "content": self.system_prompt()}]
|
| 152 |
+
+ history
|
| 153 |
+
+ [{"role": "user", "content": message}]
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
# Clients
|
| 157 |
+
gemini_client = OpenAI(
|
| 158 |
+
api_key=os.getenv("GOOGLE_API_KEY"),
|
| 159 |
+
base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
openai_client = OpenAI(
|
| 163 |
+
api_key=os.getenv("OPENAI_API_KEY")
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
def call_llm(client, model):
|
| 167 |
+
return client.chat.completions.create(
|
| 168 |
+
model=model,
|
| 169 |
+
messages=messages,
|
| 170 |
+
tools=tools
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
done = False
|
| 174 |
+
use_openai = False
|
| 175 |
+
|
| 176 |
while not done:
|
| 177 |
+
try:
|
| 178 |
+
# 🔹 Try Gemini first
|
| 179 |
+
if not use_openai:
|
| 180 |
+
response = call_llm(gemini_client, "gemini-2.0-flash")
|
| 181 |
+
else:
|
| 182 |
+
response = call_llm(openai_client, "gpt-4o-mini")
|
| 183 |
+
|
| 184 |
+
except Exception as e:
|
| 185 |
+
error_msg = str(e).lower()
|
| 186 |
+
|
| 187 |
+
# 🔥 Detect quota exceeded
|
| 188 |
+
if "quota" in error_msg or "resource_exhausted" in error_msg:
|
| 189 |
+
print("⚠️ Gemini quota exceeded. Falling back to OpenAI...")
|
| 190 |
+
use_openai = True
|
| 191 |
+
continue
|
| 192 |
+
|
| 193 |
+
# ❌ Unknown error
|
| 194 |
+
print("❌ LLM error:", e)
|
| 195 |
+
return "Sorry, something went wrong while processing your request."
|
| 196 |
+
|
| 197 |
+
# 🔁 Tool calling flow
|
| 198 |
+
choice = response.choices[0]
|
| 199 |
+
|
| 200 |
+
if choice.finish_reason == "tool_calls":
|
| 201 |
+
assistant_message = choice.message
|
| 202 |
+
tool_calls = assistant_message.tool_calls
|
| 203 |
+
|
| 204 |
+
tool_results = self.handle_tool_call(tool_calls)
|
| 205 |
+
|
| 206 |
+
messages.append(assistant_message)
|
| 207 |
+
messages.extend(tool_results)
|
| 208 |
else:
|
| 209 |
done = True
|
| 210 |
+
|
| 211 |
return response.choices[0].message.content
|
| 212 |
|
| 213 |
|
| 214 |
+
|
| 215 |
if __name__ == "__main__":
|
| 216 |
me = Me()
|
| 217 |
with gr.Blocks(
|
me/summary.txt
CHANGED
|
@@ -1,31 +1 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
CERTIFICATIONS / ACHIEVEMENT
|
| 4 |
-
Got Appreciation for creating terraform blueprint for aws ECS infrastructure.
|
| 5 |
-
Got Appreciation for successfully rolling out reservation features for EV vehicles.
|
| 6 |
-
Spring Boot Microservices Developer (Udemy & Wipro)
|
| 7 |
-
Hibernate Level 1 (Wipro)
|
| 8 |
-
DevOps Level 1 (Wipro)
|
| 9 |
-
React.js (Great Learning)
|
| 10 |
-
|
| 11 |
-
Certified on wipro internal & Udemy spring-boot microservices developer.
|
| 12 |
-
Certified on wipro internal & Udemy Hibernate-L1.
|
| 13 |
-
Certified on wipro internal Devops-L1.
|
| 14 |
-
Certified on React.js (GreatLearning)
|
| 15 |
-
|
| 16 |
-
INTERESTED IN
|
| 17 |
-
Android Studio
|
| 18 |
-
Cloud Computing
|
| 19 |
-
AI/ML
|
| 20 |
-
Google Firebase
|
| 21 |
-
Higher Study (M.tech/M.S)
|
| 22 |
-
Developed multiple android games on self interest which uses firebase database. (KheeloJeeto.apk, ChessGameTimer.apk, TicTacToe.apk)
|
| 23 |
-
Developed an android application on self interest which is a food recipe app. (cafehouse.apk)
|
| 24 |
-
EXTRA-CURRICULAR ACTIVITIES
|
| 25 |
-
Learning new skills ( currently, exploring AI)
|
| 26 |
-
Engage with Team Member
|
| 27 |
-
|
| 28 |
-
Language - English, Hindi
|
| 29 |
-
HOBBIES
|
| 30 |
-
Singing, Playing Cricket
|
| 31 |
-
Sketching & Designing
|
|
|
|
| 1 |
+
Pawan Malhotra: Software engineer skilled in Spring Boot microservices, AWS ECS (Terraform), DevOps, and React. Awarded for ECS infra automation and EV reservation features. Certified in Spring, Hibernate, DevOps, React. Interests: Cloud, AI/ML, Android, Firebase. Built multiple Android apps. Languages: English, Hindi.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|