burtenshaw commited on
Commit
ac8a8fb
·
1 Parent(s): 13f2c6f

add hf_token

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -8,9 +8,11 @@ from huggingface_hub import whoami, InferenceClient
8
  import black # Add black import
9
 
10
  # Initialize the inference client
11
- client = InferenceClient(
12
- api_key=os.getenv("HF_API_KEY"), # Make sure to set this environment variable
 
13
  )
 
14
 
15
  # Load questions from Hugging Face dataset
16
  EXAM_MAX_QUESTIONS = int(
@@ -19,11 +21,6 @@ EXAM_MAX_QUESTIONS = int(
19
  EXAM_PASSING_SCORE = float(os.getenv("EXAM_PASSING_SCORE", 0.8))
20
  EXAM_DATASET_ID = "agents-course/smolagents-quiz-data"
21
 
22
- # inference client config
23
- HF_TOKEN = os.getenv("HF_TOKEN")
24
- HF_API_URL = os.getenv(
25
- "HF_API_URL", "https://sm6g3bin692qbz80.us-east-1.aws.endpoints.huggingface.cloud"
26
- )
27
 
28
  # prep the dataset for the quiz
29
  ds = load_dataset(EXAM_DATASET_ID, split="train", download_mode="force_redownload")
@@ -91,7 +88,6 @@ def check_code(
91
  model=HF_API_URL,
92
  messages=messages,
93
  max_tokens=500,
94
- token=HF_TOKEN,
95
  )
96
 
97
  response = completion.choices[0].message.content.strip()
 
8
  import black # Add black import
9
 
10
  # Initialize the inference client
11
+ HF_TOKEN = os.getenv("HF_TOKEN")
12
+ HF_API_URL = os.getenv(
13
+ "HF_API_URL", "https://sm6g3bin692qbz80.us-east-1.aws.endpoints.huggingface.cloud"
14
  )
15
+ client = InferenceClient(api_key=HF_TOKEN)
16
 
17
  # Load questions from Hugging Face dataset
18
  EXAM_MAX_QUESTIONS = int(
 
21
  EXAM_PASSING_SCORE = float(os.getenv("EXAM_PASSING_SCORE", 0.8))
22
  EXAM_DATASET_ID = "agents-course/smolagents-quiz-data"
23
 
 
 
 
 
 
24
 
25
  # prep the dataset for the quiz
26
  ds = load_dataset(EXAM_DATASET_ID, split="train", download_mode="force_redownload")
 
88
  model=HF_API_URL,
89
  messages=messages,
90
  max_tokens=500,
 
91
  )
92
 
93
  response = completion.choices[0].message.content.strip()