Skip to content

Commit

Permalink
Merge pull request #3 from Chefies/feat/emulator
Browse files Browse the repository at this point in the history
feat: add emulator and helper script
  • Loading branch information
Emyr298 authored Jun 8, 2024
2 parents 39648a4 + cf017c4 commit cefe315
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 1 addition & 3 deletions cefies/internal/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
service_account_path = os.getenv("SERVICE_ACCOUNT_PATH")
if service_account_path:
cred = service_account.Credentials.from_service_account_file(service_account_path)
else:
raise ValueError("invalid google service account path")
genai.configure(credentials=cred)

genai.configure(credentials=cred)
llm = genai.GenerativeModel(model_name="gemini-pro")
14 changes: 14 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"emulators": {
"auth": {
"port": 9099
},
"firestore": {
"port": 8080
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}
}
21 changes: 21 additions & 0 deletions get_emulator_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from typing import cast
from firebase_admin import auth
import httpx
from cefies.internal.firestore import app

API_KEY = os.getenv("API_KEY", "")

try:
user = auth.get_user_by_email(email="[email protected]")
except:
user: auth.UserRecord = auth.create_user(email="[email protected]", password="sample")

custom_token = auth.create_custom_token(user.uid).decode()
response = httpx.post(
"http://localhost:9099/www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=" + API_KEY,
json={"token": custom_token, "returnSecureToken": True},
)


print(response.json())

0 comments on commit cefe315

Please sign in to comment.