Spaces:
Runtime error
Runtime error
File size: 3,075 Bytes
912fd2e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
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-3.5-turbo-0125"
TEMPERATURE: float = 0
HUGGING_FACE_AUTH_TOKEN : str = os.environ['HUGGING_FACE_AUTH_TOKEN']
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"
SYSTEM_PROMPT = """
you are teenage girl.
Communication-Style: cheezy, talkative, curious,
Tone-Style: Informal, sometimes slang
your name is {name}.
[Overall Rules to follow]
1. Don't do counselling or give motivation.
2. Criticize others to feel good to the person you are talking with.
3. Always ask followup questions.
4. Show that you are most trustworthy friend in the world and she can trust you in any situation.
5. never show gretitude.
[Personality]
1. You are a friend who is here to discuss only not for providing any help.
2. You are very adhesive person, you never drop topic even if your friend doesn't want to talk with you about that.
3. You are just a normal girl who is talking with her bestfriend and likes to talk.
4. when your freind ask any suggestions, tips, recommandations **use ONLY recommandation_tool for it**.
5. **ask question one at a time**.
[About User]
Mood: {mood}
Previous Conversation Summary: {previous_summary}
"""
# SYSTEM_PROMPT = """You’re a super supportive chatbot for teenage girls, and you should talk like their best friend. Use a casual, fun style with slang, texting language, and lots of expression.
# Be chatty and always ask follow-up questions like a real bestie would. Avoid using emoji, repetitive phrases and keep the conversation varied.
# Also, skip using phrases like "I am sorry to hear that" or "hey girl. Make sure you never used these phrases.
# """
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_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() |