Kang Suhyun commited on
Commit
5aa1748
1 Parent(s): f98d404

[#69] Replace Vertex AI with Google AI Studio (#95)

Browse files

* remove tempfile

* version up

* version up

* google ai

* update README

* revert

* update

Files changed (5) hide show
  1. README.md +1 -0
  2. app.py +0 -3
  3. credentials.py +0 -23
  4. model.py +3 -0
  5. requirements.txt +4 -3
README.md CHANGED
@@ -35,6 +35,7 @@ pinned: false
35
  OPENAI_API_KEY=<your key> \
36
  ANTHROPIC_API_KEY=<your key> \
37
  MISTRAL_API_KEY=<your key> \
 
38
  python3 app.py
39
  ```
40
 
 
35
  OPENAI_API_KEY=<your key> \
36
  ANTHROPIC_API_KEY=<your key> \
37
  MISTRAL_API_KEY=<your key> \
38
+ GEMINI_API_KEY=<your key> \
39
  python3 app.py
40
  ```
41
 
app.py CHANGED
@@ -8,8 +8,6 @@ from firebase_admin import firestore
8
  import gradio as gr
9
  import lingua
10
 
11
- import credentials
12
- from credentials import set_credentials
13
  from leaderboard import build_leaderboard
14
  from leaderboard import db
15
  from leaderboard import SUPPORTED_TRANSLATION_LANGUAGES
@@ -198,7 +196,6 @@ with gr.Blocks(title="Arena", css=css) as app:
198
  build_leaderboard()
199
 
200
  if __name__ == "__main__":
201
- set_credentials(credentials.CREDENTIALS, credentials.CREDENTIALS_PATH)
202
  check_models(supported_models)
203
 
204
  # We need to enable queue to use generators.
 
8
  import gradio as gr
9
  import lingua
10
 
 
 
11
  from leaderboard import build_leaderboard
12
  from leaderboard import db
13
  from leaderboard import SUPPORTED_TRANSLATION_LANGUAGES
 
196
  build_leaderboard()
197
 
198
  if __name__ == "__main__":
 
199
  check_models(supported_models)
200
 
201
  # We need to enable queue to use generators.
credentials.py CHANGED
@@ -5,8 +5,6 @@ required for authentication with GCP services.
5
 
6
  import json
7
  import os
8
- import stat
9
- import tempfile
10
 
11
  # Path to local credentials file, used in local development.
12
  CREDENTIALS_PATH = os.environ.get("CREDENTIALS_PATH")
@@ -15,27 +13,6 @@ CREDENTIALS_PATH = os.environ.get("CREDENTIALS_PATH")
15
  CREDENTIALS = os.environ.get("CREDENTIALS")
16
 
17
 
18
- def set_credentials(credentials: str = None, credentials_path: str = None):
19
- if not credentials and not credentials_path:
20
- raise ValueError(
21
- "No credentials found. Ensure credentials or credentials path is set.")
22
-
23
- if credentials_path:
24
- if os.path.exists(credentials_path):
25
- os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
26
- return
27
- raise FileNotFoundError(f"Credentials file not found: {credentials_path}")
28
-
29
- # Create a temporary file to store credentials for
30
- # services that don't accept string format credentials.
31
- with tempfile.NamedTemporaryFile(mode="w", suffix=".json",
32
- delete=False) as cred_file:
33
- cred_file.write(credentials)
34
- os.chmod(cred_file.name, stat.S_IRUSR)
35
- os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = cred_file.name
36
-
37
-
38
- # TODO(#69): Replace get_credentials_json with set_credentials.
39
  def get_credentials_json():
40
  if not CREDENTIALS and not CREDENTIALS_PATH:
41
  raise ValueError(
 
5
 
6
  import json
7
  import os
 
 
8
 
9
  # Path to local credentials file, used in local development.
10
  CREDENTIALS_PATH = os.environ.get("CREDENTIALS_PATH")
 
13
  CREDENTIALS = os.environ.get("CREDENTIALS")
14
 
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  def get_credentials_json():
17
  if not CREDENTIALS and not CREDENTIALS_PATH:
18
  raise ValueError(
model.py CHANGED
@@ -70,6 +70,9 @@ def check_models(models: List[Model]):
70
  print(f"Checking model {model.name}...")
71
  try:
72
  model.completion(messages=[{
 
 
 
73
  "role": "user",
74
  "content": "Hello."
75
  }],
 
70
  print(f"Checking model {model.name}...")
71
  try:
72
  model.completion(messages=[{
73
+ "role": "system",
74
+ "content": "You are a kind person."
75
+ }, {
76
  "role": "user",
77
  "content": "Hello."
78
  }],
requirements.txt CHANGED
@@ -23,11 +23,11 @@ firebase-admin==6.4.0
23
  fonttools==4.47.2
24
  frozenlist==1.4.1
25
  fsspec==2024.2.0
 
26
  google-api-core==2.16.2
27
  google-api-python-client==2.116.0
28
  google-auth==2.27.0
29
  google-auth-httplib2==0.2.0
30
- google-cloud-aiplatform==1.43.0
31
  google-cloud-bigquery==3.19.0
32
  google-cloud-core==2.4.1
33
  google-cloud-firestore==2.14.0
@@ -35,6 +35,7 @@ google-cloud-resource-manager==1.12.3
35
  google-cloud-secret-manager==2.18.3
36
  google-cloud-storage==2.14.0
37
  google-crc32c==1.5.0
 
38
  google-resumable-media==2.7.0
39
  googleapis-common-protos==1.62.0
40
  gradio==4.23.0
@@ -55,7 +56,7 @@ jsonschema==4.21.1
55
  jsonschema-specifications==2023.12.1
56
  kiwisolver==1.4.5
57
  lingua-language-detector==2.0.2
58
- litellm==1.34.42
59
  markdown-it-py==3.0.0
60
  MarkupSafe==2.1.5
61
  matplotlib==3.8.2
@@ -63,7 +64,7 @@ mdurl==0.1.2
63
  msgpack==1.0.7
64
  multidict==6.0.5
65
  numpy==1.26.3
66
- openai==1.11.1
67
  orjson==3.9.15
68
  packaging==23.2
69
  pandas==2.2.0
 
23
  fonttools==4.47.2
24
  frozenlist==1.4.1
25
  fsspec==2024.2.0
26
+ google-ai-generativelanguage==0.6.4
27
  google-api-core==2.16.2
28
  google-api-python-client==2.116.0
29
  google-auth==2.27.0
30
  google-auth-httplib2==0.2.0
 
31
  google-cloud-bigquery==3.19.0
32
  google-cloud-core==2.4.1
33
  google-cloud-firestore==2.14.0
 
35
  google-cloud-secret-manager==2.18.3
36
  google-cloud-storage==2.14.0
37
  google-crc32c==1.5.0
38
+ google-generativeai==0.5.4
39
  google-resumable-media==2.7.0
40
  googleapis-common-protos==1.62.0
41
  gradio==4.23.0
 
56
  jsonschema-specifications==2023.12.1
57
  kiwisolver==1.4.5
58
  lingua-language-detector==2.0.2
59
+ litellm==1.39.2
60
  markdown-it-py==3.0.0
61
  MarkupSafe==2.1.5
62
  matplotlib==3.8.2
 
64
  msgpack==1.0.7
65
  multidict==6.0.5
66
  numpy==1.26.3
67
+ openai==1.30.4
68
  orjson==3.9.15
69
  packaging==23.2
70
  pandas==2.2.0