Spaces:
Runtime error
Runtime error
Upload bot.py
Browse files
bot.py
CHANGED
|
@@ -6,11 +6,17 @@ import fire
|
|
| 6 |
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# === Bot Loaders ===
|
| 10 |
|
| 11 |
|
| 12 |
def load_bot(
|
| 13 |
-
env_file_path: str = ".env",
|
| 14 |
logging_config_path: str = "logging.yaml",
|
| 15 |
model_cache_dir: str = "/model_cache",
|
| 16 |
embedding_model_device: str = "cuda:0",
|
|
@@ -84,47 +90,6 @@ def load_bot_dev(
|
|
| 84 |
# === Bot Runners ===
|
| 85 |
|
| 86 |
|
| 87 |
-
@financial_bot.rest_api(keep_warm_seconds=300, loader=load_bot)
|
| 88 |
-
def run(**inputs):
|
| 89 |
-
"""
|
| 90 |
-
Run the bot under the Beam RESTful API endpoint.
|
| 91 |
-
|
| 92 |
-
Args:
|
| 93 |
-
inputs (dict): A dictionary containing the following keys:
|
| 94 |
-
- context: The bot instance.
|
| 95 |
-
- about_me (str): Information about the user.
|
| 96 |
-
- question (str): The user's question.
|
| 97 |
-
- history (list): A list of previous conversations (optional).
|
| 98 |
-
|
| 99 |
-
Returns:
|
| 100 |
-
str: The bot's response to the user's question.
|
| 101 |
-
"""
|
| 102 |
-
|
| 103 |
-
response = _run(**inputs)
|
| 104 |
-
|
| 105 |
-
return response
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
@financial_bot_dev.rest_api(keep_warm_seconds=300, loader=load_bot_dev)
|
| 109 |
-
def run_dev(**inputs):
|
| 110 |
-
"""
|
| 111 |
-
Run the bot under the Beam RESTful API endpoint [Dev Mode].
|
| 112 |
-
|
| 113 |
-
Args:
|
| 114 |
-
inputs (dict): A dictionary containing the following keys:
|
| 115 |
-
- context: The bot instance.
|
| 116 |
-
- about_me (str): Information about the user.
|
| 117 |
-
- question (str): The user's question.
|
| 118 |
-
- history (list): A list of previous conversations (optional).
|
| 119 |
-
|
| 120 |
-
Returns:
|
| 121 |
-
str: The bot's response to the user's question.
|
| 122 |
-
"""
|
| 123 |
-
|
| 124 |
-
response = _run(**inputs)
|
| 125 |
-
|
| 126 |
-
return response
|
| 127 |
-
|
| 128 |
|
| 129 |
def run_local(
|
| 130 |
about_me: str,
|
|
|
|
| 6 |
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
| 9 |
+
open_api_key = os.getenv("COMET_API_KEY")
|
| 10 |
+
open_api_key = os.getenv("COMET_WORKSPACE")
|
| 11 |
+
open_api_key = os.getenv("COMET_PROJECT_NAME")
|
| 12 |
+
open_api_key = os.getenv("QDRANT_URL")
|
| 13 |
+
open_api_key = os.getenv("QDRANT_API_KEY")
|
| 14 |
+
|
| 15 |
# === Bot Loaders ===
|
| 16 |
|
| 17 |
|
| 18 |
def load_bot(
|
| 19 |
+
# env_file_path: str = ".env",
|
| 20 |
logging_config_path: str = "logging.yaml",
|
| 21 |
model_cache_dir: str = "/model_cache",
|
| 22 |
embedding_model_device: str = "cuda:0",
|
|
|
|
| 90 |
# === Bot Runners ===
|
| 91 |
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
def run_local(
|
| 95 |
about_me: str,
|