| import json |
| import os |
| import re |
|
|
|
|
| |
| OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") |
| PINECONE_KEY = os.getenv("PINECONE_KEY") |
| PINECONE_ENV = os.getenv("PINECONE_ENV") |
| FIREBASE_ENV = os.getenv("FIREBASE_SERVICE_ACCOUNT_TEST3_83FFC") |
|
|
| |
| PROXY_IP = os.getenv("PROXY_IP") |
| PROXY_PORT = os.getenv("PROXY_PORT") |
|
|
| |
| swagger_destination_path = "./src/static/swagger.json" |
| SWAGGER_URL = "/api/docs" |
| API_URL = "http://localhost:5000/file/swagger.json" |
|
|
| |
| FIREBASE_STORAGE_ROOT = "images/" |
| FIREBASE_STORAGE_BUCKET = "test3-83ffc.appspot.com" |
| FIREBASE_REALTIME_DATABASE = "https://test3-83ffc-default-rtdb.firebaseio.com/" |
|
|
| |
| PINECONE_NAMESPACE = "risinglangchain-namespace" |
| PINECONE_INDEX_NAME = "risinglangchain-index" |
|
|
| |
| DEFAULT_GPT_MODEL = "gpt-4" |
|
|
| |
| AGENT_NAME = "RisingBrain Assistant" |
|
|
| |
| COMMAND_SMS_INDEXES = ["pWDrks5DO1bEPLlUtQ1f", "LEpAhmFi8tAOQUE7LHZZ"] |
| COMMAND_BROWSER_OPEN = ["taVNeDINonUqJWXBlESU"] |
|
|
| |
| ACCOUNT_SID = os.getenv("TWILIO_ACCOUNT_SID") |
| AUTH_TOKEN = os.getenv("TWILIO_AUTH_TOKEN") |
| |
| HUGGINGFACEHUB_API_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN") |
|
|
|
|
| |
| ACTION_FLAG = True |
|
|
|
|
| class ProgramType: |
| BROWSER = "browser" |
| ALERT = "alert" |
| IMAGE = "image" |
| SMS = "sms" |
| CONTACT = "contact" |
| MESSAGE = "message" |
| AUTO_TASK = "autotask" |
| RAILS_OFF_TOPIC = "rails_off_topic" |
|
|
|
|
| |
| def validateJSON(jsonData): |
| try: |
| json.loads(jsonData) |
| except ValueError as err: |
| return False |
| return True |
|
|
|
|
| def parseJsonFromCompletion(data: str) -> json: |
| result = data[1:-1] |
| array = result.split('\\"') |
| |
| if len(array) > 1: |
| array[0] = array[0].replace("'", '"') |
| result = array[0] + '"' + array[1] + '"' + array[2] |
| else: |
| result = result.replace("{'", '{"') |
| result = result.replace("'}", '"}') |
| result = result.replace("': '", '": "') |
| result = result.replace("': \\\"", '": \"') |
| result = result.replace("', '", '", "') |
| result = result.replace("':", '":') |
|
|
| substring = '\\"}' |
| replacement = '\"}' |
|
|
| index = result.rfind(substring) |
|
|
| if index == len(result) - 3: |
| result = result[:index] + replacement + result[index + len(substring):] |
| |
| try: |
| return json.loads(result) |
| except Exception as e: |
| return result |
|
|
|
|
| def parseUrlFromStr(text: str) -> str: |
| |
| link = re.search(r"(https?://\S+)", text) |
|
|
| if link: |
| return link.group(0) |
| else: |
| return "" |
|
|