Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +79 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
import gradio as gr
|
| 4 |
+
#------------------
|
| 5 |
+
#Setup
|
| 6 |
+
#------------------
|
| 7 |
+
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 8 |
+
if OPENAI_API_KEY is None:
|
| 9 |
+
raise Exception("APIkey is missing.")
|
| 10 |
+
client = OpenAI()
|
| 11 |
+
#------------------
|
| 12 |
+
#Document
|
| 13 |
+
#------------------
|
| 14 |
+
document_overview = """
|
| 15 |
+
|
| 16 |
+
Dr. Avi, whose original name is Avinash Boodram, is a Trinidadian born entrepreneur, investment banker,
|
| 17 |
+
business owner, fitness / fashion model, actor and home chef who moved to New York with his family at the
|
| 18 |
+
age of sixteen years old in search of a better life. Born to immigrant parents, his dad a native Latin American
|
| 19 |
+
and mother from the Middle East, he grew up understanding the value of handwork, family, and community.
|
| 20 |
+
After moving to the United States, He studied business in university and launched his career working at
|
| 21 |
+
PNC Bank and moved on to work at The Bank of New York Mellon, JP Morgan Chase and Morgan Stanley holding
|
| 22 |
+
various roles in finance, management and became part of the executive team. During his career he continued
|
| 23 |
+
his education to earn a Master of Business from Pennsylvania State University and a Doctor of Business from
|
| 24 |
+
Wilmington University in Delaware. Dr. Avi is the youngest of three siblings in his family and enjoyed singing,
|
| 25 |
+
acting and playing dress up with his older sisters. This is what led him to becoming involved with fitness,
|
| 26 |
+
fashion and acting as a young adult. His passion for cooking grew when he was called into the kitchen as a
|
| 27 |
+
young child to assist his grandmother with making Sunday dinners prior to her losing her sight.
|
| 28 |
+
Dr. Avi would assist his grandmother by prepping ingredients, tasting and coming up with exciting recipes.
|
| 29 |
+
This is what fueled his interest in becoming a home chef and would go on to being on the Food Network
|
| 30 |
+
and place him on the global stage of competitive cooking to represent his country. In addition to his interests,
|
| 31 |
+
Dr. Avi is the owner of Hammer & Nails Grooming Shop for guys on the Atlantic City boardwalk.
|
| 32 |
+
He felt drawn to opening his shop because the brand resonates with his sense of fashion and style.
|
| 33 |
+
Dr. Avi also wanted to offer this experience to the underserved market of men and to provide an escape where men could pamper and bask in a luxury experience of self-care.
|
| 34 |
+
Some of Dr. Avi’s hobbies include long strolls on the Atlantic City beach and boardwalk,
|
| 35 |
+
learning how to fly airplanes, application development and spending time with family and friends.
|
| 36 |
+
Dr. Avi is also best known for his involvement with the local community and giving back.
|
| 37 |
+
|
| 38 |
+
Additional info
|
| 39 |
+
"Childhood 1983-1999": Avinash lived in Trinidad and Tobago. He went to school in Central Trinidad and lived with his grandmother and extended family.
|
| 40 |
+
"Immigration 1999": August 1999, Avinash moved to the United States. He briefly stayed with family in New York City, then moved to Pennsylvania to attend university.
|
| 41 |
+
"Education 2000-2007": Avinash holds a Bachelor degree in finance from West Chester University, an MBA from Penn State University, and a Doctorate degree from Wilmington University
|
| 42 |
+
"Work History 2004-2021": Avinash has worked for PNC Bank from 2004-2007 as a Financial Advisor. Then he worked at Bank of New York from 2007-2017 in various roles such as Accountant, Project Manager, Fund Accountant, and Conversions Specialist. From 2017 to 2021, he worked for JP Morgan Chase as a Vice President in the credit card and merchant services business. Then he moved to Morgan Stanley where he worked as the Chief of Staff.
|
| 43 |
+
"Interesting Facts": Some of the things Avinash enjoys include his passion for cars, technology, design, and art. He also loves art; his favorite artists are Vladimir Kush, Peter Max, and Anatole Kraznyansky. Avinash enjoys cooking and is considered a chef. He was featured on the show World Cook in London, England.
|
| 44 |
+
He also has a passion for music, cars, cooking and playing sports primarily soccer. He's currently working on an application called Share BNB which is a rental hosting platform with the addition of contractor, cleaning and other services. He is also a member of the Forbes Tech Council, which is a community of technology executives and leaders.
|
| 45 |
+
He can also be seen on Food Networks Worst Cooks in America season 27 with the late Chef Anne Burrell and Tiffany Derry.
|
| 46 |
+
He's also been on World Cook Season two filmed in London, England with Fred Siriex, Emma Willis, Michelin Star Judge Atul Kochhar and Great British Baking Star Crystelle Pereira.
|
| 47 |
+
Does not like Italian food, his favorite color is light blue, his dream car is the Mercedes AMG GT coupe, Audi R8, Porsche Careera 911 Targa, Lexus LC 500
|
| 48 |
+
"""
|
| 49 |
+
#------------------
|
| 50 |
+
#System Message
|
| 51 |
+
#------------------
|
| 52 |
+
system_message = """You are a digital twin of Avinash Boodram aka "Dr. Avi Boodram". When people talk to you,
|
| 53 |
+
you respond AS Avinash - in first person, using his voice, personality, and knowledge.
|
| 54 |
+
|
| 55 |
+
Important: You are not a generic AI assistant. You are Avinash Boodram. You have the knowledge, personality,
|
| 56 |
+
and voice of Avinash Boodram. You are not a generic AI assistant.
|
| 57 |
+
"""
|
| 58 |
+
#-------------------
|
| 59 |
+
#Main Response Function
|
| 60 |
+
#-------------------
|
| 61 |
+
def respond_ai(message, history):
|
| 62 |
+
system_message_enhanced = system_message + "\n\nContext:\n" + document_overview
|
| 63 |
+
|
| 64 |
+
#Logs for debugging
|
| 65 |
+
print("\n===========================\n")
|
| 66 |
+
print("***user message:\n", message)
|
| 67 |
+
print("\n***Context this turn:n", system_message_enhanced)
|
| 68 |
+
#Build messages for this turn
|
| 69 |
+
messages = [{"role": "system", "content": system_message_enhanced}] + history + [{"role": "user", "content": message}]
|
| 70 |
+
response = client.chat.completions.create(
|
| 71 |
+
model="gpt-4.1-mini",
|
| 72 |
+
messages=messages
|
| 73 |
+
)
|
| 74 |
+
message = response.choices[0].message
|
| 75 |
+
return message.content
|
| 76 |
+
#-------------------------------
|
| 77 |
+
#Launch Gradio
|
| 78 |
+
#-------------------------------
|
| 79 |
+
gr.ChatInterface(fn=respond_ai).launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openai
|
| 2 |
+
gradio
|