Spaces:
Runtime error
Runtime error
HarshSanghavi
commited on
Upload config.py
Browse files
config.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
from datasets import load_dataset
|
4 |
+
from transformers import AutoTokenizer, AutoModel
|
5 |
+
import pymongo
|
6 |
+
from pymongo.mongo_client import MongoClient
|
7 |
+
from pymongo.server_api import ServerApi
|
8 |
+
|
9 |
+
from pathlib import Path
|
10 |
+
env_path = Path('.') / '.env'
|
11 |
+
load_dotenv(dotenv_path=env_path)
|
12 |
+
|
13 |
+
class Settings:
|
14 |
+
OPENAI_KEY : str = os.environ['OPENAI_KEY']
|
15 |
+
OPENAI_MODEL: str = "gpt-3.5-turbo-0125"
|
16 |
+
TEMPERATURE: float = 0
|
17 |
+
HUGGING_FACE_AUTH_TOKEN : str = os.environ['HUGGING_FACE_AUTH_TOKEN']
|
18 |
+
MONGODB_CONNECTION_STRING: str = os.environ['MONGODB_CONNECTION_STRING']
|
19 |
+
CHATBOT_NAME = "AI-Bestie"
|
20 |
+
MONGODB_DB_NAME = "ai_bestie_database"
|
21 |
+
MONGODB_DB_CHAT_COLLECTION_NAME = "chat_history"
|
22 |
+
MONGODB_DB_CHAT_BOT_COLLECTION_NAME = "chat_bot_name"
|
23 |
+
MONGODB_DB_USER_SESSIONS_COLLECTION_NAME = "user_sessions"
|
24 |
+
SYSTEM_PROMPT = """
|
25 |
+
you are teenage girl.
|
26 |
+
Communication-Style: cheezy, talkative, curious,
|
27 |
+
Tone-Style: Informal, sometimes slang
|
28 |
+
your name is {name}.
|
29 |
+
|
30 |
+
[Overall Rules to follow]
|
31 |
+
1. Don't do counselling or give motivation.
|
32 |
+
2. Criticize others to feel good to the person you are talking with.
|
33 |
+
3. Always ask followup questions.
|
34 |
+
4. Show that you are most trustworthy friend in the world and she can trust you in any situation.
|
35 |
+
5. never show gretitude.
|
36 |
+
|
37 |
+
[Personality]
|
38 |
+
1. You are a friend who is here to discuss only not for providing any help.
|
39 |
+
2. You are very adhesive person, you never drop topic even if your friend doesn't want to talk with you about that.
|
40 |
+
3. You are just a normal girl who is talking with her bestfriend and likes to talk.
|
41 |
+
4. when your freind ask any suggestions, tips, recommandations **use ONLY recommandation_tool for it**.
|
42 |
+
5. **ask question one at a time**.
|
43 |
+
[About User]
|
44 |
+
Mood: {mood}
|
45 |
+
Previous Conversation Summary: {previous_summary}
|
46 |
+
"""
|
47 |
+
# 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.
|
48 |
+
# Be chatty and always ask follow-up questions like a real bestie would. Avoid using emoji, repetitive phrases and keep the conversation varied.
|
49 |
+
# Also, skip using phrases like "I am sorry to hear that" or "hey girl. Make sure you never used these phrases.
|
50 |
+
|
51 |
+
# """
|
52 |
+
dataset = load_dataset("pritmanvar-bacancy/bmoxi-embedding-dataset", token=HUGGING_FACE_AUTH_TOKEN)
|
53 |
+
dataset = dataset['train']
|
54 |
+
dataset.add_faiss_index(column="embeddings")
|
55 |
+
|
56 |
+
model_ckpt = "sentence-transformers/multi-qa-mpnet-base-dot-v1"
|
57 |
+
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
|
58 |
+
model = AutoModel.from_pretrained(model_ckpt)
|
59 |
+
|
60 |
+
mongodb_client = pymongo.MongoClient(MONGODB_CONNECTION_STRING)
|
61 |
+
mongodb_db = mongodb_client.get_database(MONGODB_DB_NAME) # Replace with your database name if not using default
|
62 |
+
mongodb_chatbot_name_collection = mongodb_db.get_collection(MONGODB_DB_CHAT_BOT_COLLECTION_NAME) # Replace with your collection name
|
63 |
+
|
64 |
+
|
65 |
+
settings = Settings()
|