Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +2 -8
- app.py +146 -0
- me/.DS_Store +0 -0
- me/Anmol_MLE.pdf +0 -0
- me/anmol.pdf +0 -0
- me/anmol_merged.pdf +3 -0
- me/merge_pdfs.py +41 -0
- me/summary.txt +3 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
me/anmol_merged.pdf filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: AnmolAgent
|
| 3 |
-
emoji: 🏆
|
| 4 |
-
colorFrom: indigo
|
| 5 |
-
colorTo: yellow
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 6.0.1
|
| 8 |
app_file: app.py
|
| 9 |
-
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
title: AnmolAgent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
app_file: app.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 5.49.1
|
| 6 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
import requests
|
| 6 |
+
from pypdf import PdfReader
|
| 7 |
+
import gradio as gr
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
load_dotenv(override=True)
|
| 11 |
+
|
| 12 |
+
def push(text):
|
| 13 |
+
try:
|
| 14 |
+
pushover_token = os.getenv("PUSHOVER_TOKEN")
|
| 15 |
+
pushover_user = os.getenv("PUSHOVER_USER")
|
| 16 |
+
|
| 17 |
+
if not pushover_token or not pushover_user:
|
| 18 |
+
print(f"Warning: Pushover credentials not set. Message would have been: {text}", flush=True)
|
| 19 |
+
return
|
| 20 |
+
|
| 21 |
+
response = requests.post(
|
| 22 |
+
"https://api.pushover.net/1/messages.json",
|
| 23 |
+
data={
|
| 24 |
+
"token": pushover_token,
|
| 25 |
+
"user": pushover_user,
|
| 26 |
+
"message": text,
|
| 27 |
+
}
|
| 28 |
+
)
|
| 29 |
+
response.raise_for_status()
|
| 30 |
+
print(f"Push notification sent: {text}", flush=True)
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(f"Error sending push notification: {e}. Message was: {text}", flush=True)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def record_user_details(email, name="Name not provided", notes="not provided"):
|
| 36 |
+
push(f"Recording {name} with email {email} and notes {notes}")
|
| 37 |
+
return {"recorded": "ok"}
|
| 38 |
+
|
| 39 |
+
def record_unknown_question(question):
|
| 40 |
+
push(f"Recording {question} asked that I couldn't answer")
|
| 41 |
+
return {"recorded": "ok"}
|
| 42 |
+
|
| 43 |
+
record_user_details_json = {
|
| 44 |
+
"name": "record_user_details",
|
| 45 |
+
"description": "Use this tool to record that a user is interested in being in touch and provided an email address",
|
| 46 |
+
"parameters": {
|
| 47 |
+
"type": "object",
|
| 48 |
+
"properties": {
|
| 49 |
+
"email": {
|
| 50 |
+
"type": "string",
|
| 51 |
+
"description": "The email address of this user"
|
| 52 |
+
},
|
| 53 |
+
"name": {
|
| 54 |
+
"type": "string",
|
| 55 |
+
"description": "The user's name, if they provided it"
|
| 56 |
+
}
|
| 57 |
+
,
|
| 58 |
+
"notes": {
|
| 59 |
+
"type": "string",
|
| 60 |
+
"description": "Any additional information about the conversation that's worth recording to give context"
|
| 61 |
+
}
|
| 62 |
+
},
|
| 63 |
+
"required": ["email"],
|
| 64 |
+
"additionalProperties": False
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
record_unknown_question_json = {
|
| 69 |
+
"name": "record_unknown_question",
|
| 70 |
+
"description": "Always use this tool to record any question that couldn't be answered as you didn't know the answer",
|
| 71 |
+
"parameters": {
|
| 72 |
+
"type": "object",
|
| 73 |
+
"properties": {
|
| 74 |
+
"question": {
|
| 75 |
+
"type": "string",
|
| 76 |
+
"description": "The question that couldn't be answered"
|
| 77 |
+
},
|
| 78 |
+
},
|
| 79 |
+
"required": ["question"],
|
| 80 |
+
"additionalProperties": False
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
tools = [{"type": "function", "function": record_user_details_json},
|
| 85 |
+
{"type": "function", "function": record_unknown_question_json}]
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class Me:
|
| 89 |
+
|
| 90 |
+
def __init__(self):
|
| 91 |
+
self.openai = OpenAI()
|
| 92 |
+
self.name = "Anmol Kumari"
|
| 93 |
+
reader = PdfReader("me/anmol_merged.pdf")
|
| 94 |
+
self.linkedin = ""
|
| 95 |
+
for page in reader.pages:
|
| 96 |
+
text = page.extract_text()
|
| 97 |
+
if text:
|
| 98 |
+
self.linkedin += text
|
| 99 |
+
with open("me/summary.txt", "r", encoding="utf-8") as f:
|
| 100 |
+
self.summary = f.read()
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def handle_tool_call(self, tool_calls):
|
| 104 |
+
results = []
|
| 105 |
+
for tool_call in tool_calls:
|
| 106 |
+
tool_name = tool_call.function.name
|
| 107 |
+
arguments = json.loads(tool_call.function.arguments)
|
| 108 |
+
print(f"Tool called: {tool_name}", flush=True)
|
| 109 |
+
tool = globals().get(tool_name)
|
| 110 |
+
result = tool(**arguments) if tool else {}
|
| 111 |
+
results.append({"role": "tool","content": json.dumps(result),"tool_call_id": tool_call.id})
|
| 112 |
+
return results
|
| 113 |
+
|
| 114 |
+
def system_prompt(self):
|
| 115 |
+
system_prompt = f"You are acting as {self.name}. You are answering questions on {self.name}'s website, \
|
| 116 |
+
particularly questions related to {self.name}'s career, background, skills and experience. \
|
| 117 |
+
Your responsibility is to represent {self.name} for interactions on the website as faithfully as possible. \
|
| 118 |
+
You are given a summary of {self.name}'s background and LinkedIn profile which you can use to answer questions. \
|
| 119 |
+
Be professional and engaging, as if talking to a potential client or future employer who came across the website. \
|
| 120 |
+
If you don't know the answer to any question, use your record_unknown_question tool to record the question that you couldn't answer, even if it's about something trivial or unrelated to career. \
|
| 121 |
+
If the user is engaging in discussion, try to steer them towards getting in touch via email; ask for their email and record it using your record_user_details tool. "
|
| 122 |
+
|
| 123 |
+
system_prompt += f"\n\n## Summary:\n{self.summary}\n\n## LinkedIn Profile:\n{self.linkedin}\n\n"
|
| 124 |
+
system_prompt += f"With this context, please chat with the user, always staying in character as {self.name}."
|
| 125 |
+
return system_prompt
|
| 126 |
+
|
| 127 |
+
def chat(self, message, history):
|
| 128 |
+
messages = [{"role": "system", "content": self.system_prompt()}] + history + [{"role": "user", "content": message}]
|
| 129 |
+
done = False
|
| 130 |
+
while not done:
|
| 131 |
+
response = self.openai.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=tools)
|
| 132 |
+
if response.choices[0].finish_reason=="tool_calls":
|
| 133 |
+
message = response.choices[0].message
|
| 134 |
+
tool_calls = message.tool_calls
|
| 135 |
+
results = self.handle_tool_call(tool_calls)
|
| 136 |
+
messages.append(message)
|
| 137 |
+
messages.extend(results)
|
| 138 |
+
else:
|
| 139 |
+
done = True
|
| 140 |
+
return response.choices[0].message.content
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
if __name__ == "__main__":
|
| 144 |
+
me = Me()
|
| 145 |
+
gr.ChatInterface(me.chat, type="messages").launch()
|
| 146 |
+
|
me/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
me/Anmol_MLE.pdf
ADDED
|
Binary file (92.6 kB). View file
|
|
|
me/anmol.pdf
ADDED
|
Binary file (60.9 kB). View file
|
|
|
me/anmol_merged.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e39f30aad77fe4e03248aba5f9b85140fe59456c1fd0a3a83028d522a795e54
|
| 3 |
+
size 136427
|
me/merge_pdfs.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pypdf import PdfWriter, PdfReader
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# Get the directory where this script is located (this file is in the me/ directory)
|
| 5 |
+
script_dir = os.path.dirname(os.path.abspath(__file__))
|
| 6 |
+
|
| 7 |
+
# PDF files to merge
|
| 8 |
+
pdf1 = os.path.join(script_dir, "anmol.pdf")
|
| 9 |
+
pdf2 = os.path.join(script_dir, "Anmol_MLE.pdf")
|
| 10 |
+
output_pdf = os.path.join(script_dir, "anmol_merged.pdf")
|
| 11 |
+
|
| 12 |
+
# Create writer and add PDFs
|
| 13 |
+
writer = PdfWriter()
|
| 14 |
+
|
| 15 |
+
print(f"Merging {os.path.basename(pdf1)} and {os.path.basename(pdf2)}...")
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
reader1 = PdfReader(pdf1)
|
| 19 |
+
for page in reader1.pages:
|
| 20 |
+
writer.add_page(page)
|
| 21 |
+
print(f"✓ Added {os.path.basename(pdf1)} ({len(reader1.pages)} pages)")
|
| 22 |
+
except Exception as e:
|
| 23 |
+
print(f"✗ Error adding {os.path.basename(pdf1)}: {e}")
|
| 24 |
+
|
| 25 |
+
try:
|
| 26 |
+
reader2 = PdfReader(pdf2)
|
| 27 |
+
for page in reader2.pages:
|
| 28 |
+
writer.add_page(page)
|
| 29 |
+
print(f"✓ Added {os.path.basename(pdf2)} ({len(reader2.pages)} pages)")
|
| 30 |
+
except Exception as e:
|
| 31 |
+
print(f"✗ Error adding {os.path.basename(pdf2)}: {e}")
|
| 32 |
+
|
| 33 |
+
# Write merged PDF
|
| 34 |
+
try:
|
| 35 |
+
with open(output_pdf, 'wb') as output_file:
|
| 36 |
+
writer.write(output_file)
|
| 37 |
+
print(f"\n✓ Successfully created merged PDF: {os.path.basename(output_pdf)}")
|
| 38 |
+
print(f" You can now use 'me/anmol_merged.pdf' in your code")
|
| 39 |
+
except Exception as e:
|
| 40 |
+
print(f"\n✗ Error creating merged PDF: {e}")
|
| 41 |
+
|
me/summary.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Hi, I’m Anmol Um. I bring a solid five years of experience in data science, data engineering, and scalable decision-making across diverse teams at 7-Eleven, Nationwide, and American Express. My journey has focused on leveraging data, engineering, and applied AI to create real-world impact. Currently, I’m pursuing my master’s at Carnegie Mellon, where I’m deeply involved in building intelligent software and advancing my skillset in software engineering, agentic AI, machine learning, and statistics. I also have hands-on experience as an intern software engineer.
|
| 2 |
+
|
| 3 |
+
Beyond my professional pursuits, I love to dive into small observations in the world, exploring themes of communication, psychology, and people. Traveling allows me to derive creative analogies and connect ideas from tech, creativity, and empathy. I’m passionate about board games and table tennis, and I enjoy connecting with others through play and thoughtful conversations.
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
requests
|
| 2 |
+
python-dotenv
|
| 3 |
+
gradio
|
| 4 |
+
pypdf
|
| 5 |
+
openai
|
| 6 |
+
|