Add cohere(Coral) Ai support
This commit is contained in:
12
install.sh
12
install.sh
@@ -86,7 +86,16 @@ echo "You can get it here -> https://makersuite.google.com/app/apikey"
|
||||
read -r -p "GEMINI_KEY > " gemini_key
|
||||
|
||||
if [[ $gemini_key = "" ]]; then
|
||||
echo "NOTE: API Not set you'll not be able to use AI modules"
|
||||
echo "NOTE: API Not set you'll not be able to use Gemini AI modules"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Enter COHERE_KEY if you want to use AI"
|
||||
echo "You can get it here -> https://dashboard.cohere.com/api-keys"
|
||||
read -r -p "COHERE_KEY > " cohere_key
|
||||
|
||||
if [[ $cohere_key = "" ]]; then
|
||||
echo "NOTE: API Not set you'll not be able to use Coral AI modules"
|
||||
fi
|
||||
|
||||
echo
|
||||
@@ -151,6 +160,7 @@ RMBG_KEY=${rmbg_key}
|
||||
VT_KEY=${vt_key}
|
||||
GEMINI_KEY=${gemini_key}
|
||||
VCA_API_KEY=${vca_api_key}
|
||||
COHERE_KEY=${cohere_key}
|
||||
PM_LIMIT=${pm_limit}
|
||||
EOL
|
||||
|
||||
|
||||
@@ -79,7 +79,16 @@ echo "You can get it here -> https://makersuite.google.com/app/apikey"
|
||||
read -r -p "GEMINI_KEY > " gemini_key
|
||||
|
||||
if [[ $gemini_key = "" ]]; then
|
||||
echo "NOTE: API Not set you'll not be able to use AI modules"
|
||||
echo "NOTE: API Not set you'll not be able to use Gemini AI modules"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Enter COHERE_KEY if you want to use AI"
|
||||
echo "You can get it here -> https://dashboard.cohere.com/api-keys"
|
||||
read -r -p "COHERE_KEY > " cohere_key
|
||||
|
||||
if [[ $cohere_key = "" ]]; then
|
||||
echo "NOTE: API Not set you'll not be able to use Coral AI modules"
|
||||
fi
|
||||
|
||||
echo
|
||||
@@ -142,6 +151,7 @@ APIFLASH_KEY=${apiflash_key}
|
||||
RMBG_KEY=${rmbg_key}
|
||||
VT_KEY=${vt_key}
|
||||
GEMINI_KEY=${gemini_key}
|
||||
COHERE_KEY=${cohere_key}
|
||||
VCA_API_KEY=${vca_api_key}
|
||||
EOL
|
||||
|
||||
|
||||
@@ -75,7 +75,16 @@ echo "You can get it here -> https://makersuite.google.com/app/apikey"
|
||||
read -r -p "GEMINI_KEY > " gemini_key
|
||||
|
||||
if [[ $gemini_key = "" ]]; then
|
||||
echo "NOTE: API Not set you'll not be able to use AI modules"
|
||||
echo "NOTE: API Not set you'll not be able to use Gemini AI modules"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Enter COHERE_KEY if you want to use AI"
|
||||
echo "You can get it here -> https://dashboard.cohere.com/api-keys"
|
||||
read -r -p "COHERE_KEY > " cohere_key
|
||||
|
||||
if [[ $cohere_key = "" ]]; then
|
||||
echo "NOTE: API Not set you'll not be able to use Coral AI modules"
|
||||
fi
|
||||
|
||||
echo
|
||||
@@ -130,6 +139,7 @@ APIFLASH_KEY=${apiflash_key}
|
||||
RMBG_KEY=${rmbg_key}
|
||||
VT_KEY=${vt_key}
|
||||
GEMINI_KEY=${gemini_key}
|
||||
COHERE_KEY=${cohere_key}
|
||||
VCA_API_KEY=${vca_api_key}
|
||||
PM_LIMIT=${pm_limit}
|
||||
EOL
|
||||
|
||||
@@ -21,6 +21,7 @@ rmbg_key = os.getenv("RMBG_KEY", env.str("RMBG_KEY"))
|
||||
vt_key = os.getenv("VT_KEY", env.str("VT_KEY"))
|
||||
gemini_key = os.getenv("GEMINI_KEY", env.str("GEMINI_KEY"))
|
||||
vca_api_key = os.getenv("VCA_API_KEY", env.str("VCA_API_KEY"))
|
||||
cohere_key = os.getenv("COHERE_KEY", env.str("COHERE_KEY"))
|
||||
|
||||
pm_limit = int(os.getenv("PM_LIMIT", env.int("PM_LIMIT")))
|
||||
|
||||
|
||||
16
utils/db.py
16
utils/db.py
@@ -70,6 +70,14 @@ class MongoDatabase(Database):
|
||||
def close(self):
|
||||
self._client.close()
|
||||
|
||||
def add_chat_history(self, message):
|
||||
chat_history = db.get("core.cohere", "chat_history", default=[])
|
||||
chat_history.append(message)
|
||||
db.set("core.cohere", "chat_history", chat_history)
|
||||
|
||||
def get_chat_history(self):
|
||||
return db.get("core.cohere", "chat_history", default=[])
|
||||
|
||||
|
||||
class SqliteDatabase(Database):
|
||||
def __init__(self, file):
|
||||
@@ -163,6 +171,14 @@ class SqliteDatabase(Database):
|
||||
self._conn.commit()
|
||||
self._conn.close()
|
||||
|
||||
def add_chat_history(self, message):
|
||||
chat_history = db.get("core.cohere", "chat_history", default=[])
|
||||
chat_history.append(message)
|
||||
db.set("core.cohere", "chat_history", chat_history)
|
||||
|
||||
def get_chat_history(self):
|
||||
return db.get("core.cohere", "chat_history", default=[])
|
||||
|
||||
|
||||
if config.db_type in ["mongo", "mongodb"]:
|
||||
db = MongoDatabase(config.db_url, config.db_name)
|
||||
|
||||
Reference in New Issue
Block a user