muhtasham commited on
Commit
ce0215c
1 Parent(s): 506423b

Update app.py

Browse files

added more API keys

Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -9,6 +9,7 @@ demo = gr.Blocks()
9
 
10
  name_list = ['huggingface/bigscience/T0pp', 'huggingface/EleutherAI/gpt-j-6B', 'huggingface/gpt2-xl', 'huggingface/EleutherAI/gpt-neo-2.7B']
11
 
 
12
  examples = [#zero-shot
13
  ["Q: A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?\nA: The answer (arabic numerals) is "],
14
  #zero-shot-CoT
@@ -18,7 +19,6 @@ examples = [#zero-shot
18
  #few-shot-CoT
19
  ["Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?\nA: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.\nQ:A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?\nA:"],
20
  ]
21
- #examples from Figure 1 of the paper
22
 
23
  def calculator(num1, operation, num2):
24
  if operation == "add":
@@ -30,11 +30,16 @@ def calculator(num1, operation, num2):
30
  elif operation == "divide":
31
  return num1 / num2
32
 
 
 
 
 
33
  def complete_with_gpt(text):
34
- try:
35
- interfaces = [gr.Interface.load(name, api_key = "API_KEY2") for name in name_list]
36
- except:
37
- print("Error: API key is not valid")
 
38
  return [interface(text) for interface in interfaces]
39
 
40
  def set_example(example: list) -> dict:
 
9
 
10
  name_list = ['huggingface/bigscience/T0pp', 'huggingface/EleutherAI/gpt-j-6B', 'huggingface/gpt2-xl', 'huggingface/EleutherAI/gpt-neo-2.7B']
11
 
12
+ #examples from Figure 1 of the paper
13
  examples = [#zero-shot
14
  ["Q: A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?\nA: The answer (arabic numerals) is "],
15
  #zero-shot-CoT
 
19
  #few-shot-CoT
20
  ["Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?\nA: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.\nQ:A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?\nA:"],
21
  ]
 
22
 
23
  def calculator(num1, operation, num2):
24
  if operation == "add":
 
30
  elif operation == "divide":
31
  return num1 / num2
32
 
33
+
34
+ secrets = [API_KEY1, API_KEY2, API_KEY3, API_KEY4, API_KEY5, API_KEY6]
35
+
36
+
37
  def complete_with_gpt(text):
38
+ for secret in secrets:
39
+ try:
40
+ interfaces = [gr.Interface.load(name, api_key = "secret") for name in name_list]
41
+ except:
42
+ print("Error: API key is not valid")
43
  return [interface(text) for interface in interfaces]
44
 
45
  def set_example(example: list) -> dict: