Nolwenn commited on
Commit
7a44d0f
·
1 Parent(s): 1bf7a1e

Update secrets

Browse files
Files changed (1) hide show
  1. crs_arena/utils.py +5 -22
crs_arena/utils.py CHANGED
@@ -22,7 +22,7 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
22
  from src.model.crs_model import CRSModel
23
 
24
  # Initialize Hugging Face API
25
- HF_API = HfApi(token=st.secrets.hf.hf_token)
26
 
27
 
28
  @st.cache_resource(show_spinner="Loading CRS...", max_entries=5)
@@ -48,7 +48,7 @@ def get_crs_model(model_name: str, model_config_file: str) -> CRSModel:
48
  model_args = yaml.safe_load(open(model_config_file, "r"))
49
 
50
  if "chatgpt" in model_name:
51
- openai.api_key = st.secrets.openai.api_key
52
 
53
  # Extract crs model from name
54
  name = model_name.split("_")[0]
@@ -56,27 +56,10 @@ def get_crs_model(model_name: str, model_config_file: str) -> CRSModel:
56
  return CRSModel(name, **model_args)
57
 
58
 
59
- def execute_sql_query(query: str, params: Dict[str, str]) -> List[Any]:
60
- """Executes a SQL query with parameters.
61
-
62
- Args:
63
- query: SQL query.
64
- params: Dictionary of parameters.
65
-
66
- Returns:
67
- Output of the query.
68
- """
69
- connection = sqlite3.connect(st.secrets.db.vote_db)
70
- cursor = connection.cursor().execute(query, params)
71
- output = cursor.fetchall()
72
- connection.commit()
73
- return output
74
-
75
-
76
  def download_and_extract_models() -> None:
77
  """Downloads the models folder from the server and extracts it."""
78
  logging.debug("Downloading models folder.")
79
- models_url = st.secrets.files.models_folder_url
80
  models_targz = "models.tar.gz"
81
  models_folder = "data/models/"
82
  try:
@@ -95,7 +78,7 @@ def download_and_extract_models() -> None:
95
  def download_and_extract_item_embeddings() -> None:
96
  """Downloads the item embeddings folder from the server and extracts it."""
97
  logging.debug("Downloading item embeddings folder.")
98
- item_embeddings_url = st.secrets.files.item_embeddings_url
99
  item_embeddings_tarbz = "item_embeddings.tar.bz2"
100
  item_embeddings_folder = "data/"
101
 
@@ -134,7 +117,7 @@ async def upload_conversation_logs_to_hf(
134
  lambda: HF_API.upload_file(
135
  path_or_fileobj=conversation_log_file_path,
136
  path_in_repo=repo_filename,
137
- repo_id=st.secrets.hf.dataset_repo,
138
  repo_type="dataset",
139
  ),
140
  )
 
22
  from src.model.crs_model import CRSModel
23
 
24
  # Initialize Hugging Face API
25
+ HF_API = HfApi(token=st.secrets["hf_token"])
26
 
27
 
28
  @st.cache_resource(show_spinner="Loading CRS...", max_entries=5)
 
48
  model_args = yaml.safe_load(open(model_config_file, "r"))
49
 
50
  if "chatgpt" in model_name:
51
+ openai.api_key = st.secrets["openai_api_key"]
52
 
53
  # Extract crs model from name
54
  name = model_name.split("_")[0]
 
56
  return CRSModel(name, **model_args)
57
 
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  def download_and_extract_models() -> None:
60
  """Downloads the models folder from the server and extracts it."""
61
  logging.debug("Downloading models folder.")
62
+ models_url = st.secrets["models_folder_url"]
63
  models_targz = "models.tar.gz"
64
  models_folder = "data/models/"
65
  try:
 
78
  def download_and_extract_item_embeddings() -> None:
79
  """Downloads the item embeddings folder from the server and extracts it."""
80
  logging.debug("Downloading item embeddings folder.")
81
+ item_embeddings_url = st.secrets["item_embeddings_url"]
82
  item_embeddings_tarbz = "item_embeddings.tar.bz2"
83
  item_embeddings_folder = "data/"
84
 
 
117
  lambda: HF_API.upload_file(
118
  path_or_fileobj=conversation_log_file_path,
119
  path_in_repo=repo_filename,
120
+ repo_id=st.secrets["dataset_repo"],
121
  repo_type="dataset",
122
  ),
123
  )