forked from stanford-crfm/helm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an AutoTokenizer (stanford-crfm#1994)
- Loading branch information
1 parent
f264d65
commit 32342d9
Showing
8 changed files
with
200 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Functions used for caching.""" | ||
|
||
import os | ||
|
||
from helm.common.cache import CacheConfig, MongoCacheConfig, SqliteCacheConfig | ||
|
||
|
||
def build_cache_config(cache_path: str, mongo_uri: str, organization: str) -> CacheConfig: | ||
if mongo_uri: | ||
return MongoCacheConfig(mongo_uri, collection_name=organization) | ||
|
||
client_cache_path: str = os.path.join(cache_path, f"{organization}.sqlite") | ||
# TODO: Allow setting CacheConfig.follower_cache_path from a command line flag. | ||
return SqliteCacheConfig(client_cache_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Functions used for credentials.""" | ||
|
||
from typing import Any, Mapping, Optional | ||
|
||
from helm.common.hierarchical_logger import hlog | ||
|
||
|
||
def provide_api_key( | ||
credentials: Mapping[str, Any], host_organization: str, model: Optional[str] = None | ||
) -> Optional[str]: | ||
api_key_name = host_organization + "ApiKey" | ||
if api_key_name in credentials: | ||
hlog(f"Using host_organization api key defined in credentials.conf: {api_key_name}") | ||
return credentials[api_key_name] | ||
if "deployments" not in credentials: | ||
hlog( | ||
"WARNING: Could not find key 'deployments' in credentials.conf, " | ||
f"therefore the API key {api_key_name} should be specified." | ||
) | ||
return None | ||
deployment_api_keys = credentials["deployments"] | ||
if model is None: | ||
hlog(f"WARNING: Could not find key '{host_organization}' in credentials.conf and no model provided") | ||
return None | ||
if model not in deployment_api_keys: | ||
hlog(f"WARNING: Could not find key '{model}' under key 'deployments' in credentials.conf") | ||
return None | ||
return deployment_api_keys[model] |
Oops, something went wrong.