Skip to content

Commit

Permalink
minor warnings hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
csinva committed Nov 6, 2024
1 parent 2e2108a commit 014ef2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 14 additions & 14 deletions imodelsx/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
HF_TOKEN = os.environ.get("HF_TOKEN")
elif os.path.exists(expanduser('~/.HF_TOKEN')):
HF_TOKEN = open(expanduser('~/.HF_TOKEN'), 'r').read().strip()
if os.path.exists(expanduser('~/.OPENAI_API_KEY')):
OPENAI_API_KEY = open(expanduser('~/.OPENAI_API_KEY'), 'r').read().strip()
if os.path.exists(expanduser('~/.OPENAI_API_KEY_SHARED')):
OPENAI_API_KEY_SHARED = open(expanduser(
'~/.OPENAI_API_KEY_SHARED'), 'r').read().strip()
'''
Example usage:
# gpt-4, gpt-35-turbo, meta-llama/Llama-2-70b-hf, mistralai/Mistral-7B-v0.1
Expand Down Expand Up @@ -116,15 +111,20 @@ def __init__(self, checkpoint, seed, role, CACHE_DIR):
from openai import AzureOpenAI
from azure.identity import DefaultAzureCredential, get_bearer_token_provider

token_provider = get_bearer_token_provider(
DefaultAzureCredential(),
"https://cognitiveservices.azure.com/.default"
)
self.client = AzureOpenAI(
api_version="2024-09-01-preview",
azure_endpoint="https://dl-openai-1.openai.azure.com/",
azure_ad_token_provider=token_provider
)
try:
token_provider = get_bearer_token_provider(
DefaultAzureCredential(),
"https://cognitiveservices.azure.com/.default"
)
self.client = AzureOpenAI(
api_version="2024-09-01-preview",
azure_endpoint="https://dl-openai-2.openai.azure.com/",
azure_ad_token_provider=token_provider
)
except Exception as e:
print('failed to create client', e)
print('You may need to edit this call in order to supply your own OpenAI / AzureOpenAI key and authentication.')
traceback.print_exc()

@repeatedly_call_with_delay
def __call__(
Expand Down
2 changes: 2 additions & 0 deletions imodelsx/process_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def average_over_seeds(
def sem(x):
"""Compute standard error of the mean, ignoring NaNs"""
with warnings.catch_warnings():
# Ignore only UserWarning
warnings.simplefilter("ignore")
return scipy.stats.sem(x, ddof=0)

group_keys = [
Expand Down

0 comments on commit 014ef2a

Please sign in to comment.