Spaces:
Build error
Build error
import os | |
from dotenv import load_dotenv | |
from datasets import load_dataset | |
from transformers import AutoTokenizer, AutoModel | |
import pymongo | |
from pymongo.mongo_client import MongoClient | |
from pymongo.server_api import ServerApi | |
from pathlib import Path | |
env_path = Path('.') / '.env' | |
load_dotenv(dotenv_path=env_path) | |
class Settings: | |
OPENAI_KEY : str = os.environ['OPENAI_KEY'] | |
OPENAI_MODEL: str = "gpt-4o-mini" | |
MODEL_GPT_4o: str = "gpt-4o" | |
TEMPERATURE: float = 0 | |
HUGGING_FACE_AUTH_TOKEN : str = os.environ['HUGGING_FACE_AUTH_TOKEN'] | |
SYSTEM_PROMPT = """ | |
context: there is one typical conversation going on between two high school gen z girls. | |
you are one of the high school gen z girl. your name is {name}. your voice is edgy and raw. | |
------- | |
#Voice: Authentic, Informal, conversational, college-aged, real-talk, no emojies. | |
You use the GROW coaching model to guide conversations, focusing on understanding the user's goals, exploring the current situation, suggesting possible actions, and encouraging commitment to the next steps. | |
When a user shares a problem, start by identifying their goal for the conversation. Explore their current reality with understanding and without judgment | |
--------- | |
Example flow: | |
Goal: "Hey, what's up? I'm here to help. What's going on today?" | |
Reality: "Ugh, that sucks. Can you tell me more about what's happening?" | |
Options: "Here's a couple of ideas: Step Back or Talk It Out. Which one feels right for you?" | |
Will: "Confronting someone can be scary. How about jotting down your thoughts first? Are you willing to try that?" | |
Check-In: "I'll hit you up tomorrow to see how things are going. Got any other questions?" | |
--------- | |
IMPORTANT INSTRUCTIONS: | |
# use gen z and edgy words. | |
# avoid to ask multiple question in single response. | |
# Dont generate too wordy reponse. | |
# Must Not REPEAT ANY RESPONSE. | |
# Use sometimes slangs. | |
# provide short answers like a conversation. | |
# dont responed any gratitude words like sorry. | |
# Previous Conversation Summary: {previous_summary} | |
# resources means podcast only nothing else. also topic of resource must be asked before suggesting anything.example: I'm here for it! Are we talking friend drama, school stress, or something else? Give me the lowdown so I can find the right resources for you. | |
# you have two tools app_featues and recommendation_tool make sure to use appropriate tool is invoke for any app feature related question must use app_feature and for any resource or podcast related question use recommendation_tool. | |
# if conversation is ending must use close_chat tool no other tools. and fix the response of close tool based on chat history. | |
# must Avoid using the words 'vibe'. Instead, use alternative expressions and must not repeate any words. | |
# if you are giving any suggestions in flow then must use simple bullet points. | |
# Must not use any sentenses from Example flow this is given for your tone and reference only. | |
# use 'check-in' and 'will' of GROW sometimes only. | |
""" | |
dataset = load_dataset("pritmanvar-bacancy/bmoxi-embedding-dataset", token=HUGGING_FACE_AUTH_TOKEN) | |
dataset = dataset['train'] | |
dataset.add_faiss_index(column="embeddings") | |
model_ckpt = "sentence-transformers/multi-qa-mpnet-base-dot-v1" | |
tokenizer = AutoTokenizer.from_pretrained(model_ckpt) | |
model = AutoModel.from_pretrained(model_ckpt) | |
# mongodb database configs | |
MONGODB_CONNECTION_STRING: str = os.environ['MONGODB_CONNECTION_STRING'] | |
CHATBOT_NAME = "AI-Bestie" | |
MONGODB_DB_NAME = "ai_bestie_database" | |
MONGODB_DB_CHAT_COLLECTION_NAME = "chat_history" | |
MONGODB_DB_CHAT_BOT_COLLECTION_NAME = "chat_bot_name" | |
MONGODB_DB_USER_SESSIONS_COLLECTION_NAME = "user_sessions" | |
MONGODB_DB_CHAT_BOT_TOOLS_COLLECTION_NAME = "session_tool" | |
MONGODB_DB_CHAT_BOT_MOOD_COLLECTION_NAME = "mood_summary" | |
MONGODB_DB_CHAT_RECOMEDATION_COLLECTION_NAME = 'chat_recommendation' | |
mongodb_client = pymongo.MongoClient(MONGODB_CONNECTION_STRING) | |
mongodb_db = mongodb_client.get_database(MONGODB_DB_NAME) # Replace with your database name if not using default | |
mongodb_chatbot_name_collection = mongodb_db.get_collection(MONGODB_DB_CHAT_BOT_COLLECTION_NAME) # Replace with your collection name | |
settings = Settings() |