Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions service/banking/core_banking_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ class PaymentRequest(BaseModel):
category: Optional[str] = None
otp: Optional[str] = None

def format_contact_details(contacts, limit=None):
"""Helper function to format contact details for error messages"""
details = []
for b in contacts:
identifier = f"'{b.name}'"
if b.nickname:
identifier += f" (nickname: {b.nickname})"
if b.tag:
identifier += f" (tag: {b.tag})"
details.append(identifier)
# def format_contact_details(contacts, limit=None): #not used elsewhere
# """Helper function to format contact details for error messages"""
# details = []
# for b in contacts:
# identifier = f"'{b.name}'"
# if b.nickname:
# identifier += f" (nickname: {b.nickname})"
# if b.tag:
# identifier += f" (tag: {b.tag})"
# details.append(identifier)

if limit and len(details) > limit:
displayed = details[:limit]
more_count = len(details) - limit
return f"{', '.join(displayed)} and {more_count} more"
return ', '.join(details)
# if limit and len(details) > limit:
# displayed = details[:limit]
# more_count = len(details) - limit
# return f"{', '.join(displayed)} and {more_count} more"
# return ', '.join(details)

def find_beneficiary(db: Session, customer_id: int, to: str):
"""Find a beneficiary by name, nickname, or tag with smart conflict handling."""
Expand Down Expand Up @@ -433,7 +433,7 @@ async def search_txn(
return {"transactions": db_transactions}

@router.get("/beneficiaries")
def get_beneficiaries(
def get_beneficiaries(
customer_id: int = None,
phone: str = None,
db: Session = Depends(get_db)
Expand Down
36 changes: 18 additions & 18 deletions service/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ def get_credentials():
os.getenv("SERVICE_ACCOUNT_FILE"), scopes=SCOPES)
return credentials

def user_account_creds():
'''Get user account credentials'''
creds = None
if os.path.exists("token.json"):
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
os.getenv("GOOGLE_ACCOUNT_FILE"),
SCOPES
)
creds = flow.run_local_server(port=0)
with open("token.json", "w") as token:
token.write(creds.to_json())
return creds
# def user_account_creds(): # not used in service package
# '''Get user account credentials'''
# creds = None
# if os.path.exists("token.json"):
# creds = Credentials.from_authorized_user_file("token.json", SCOPES)
# if not creds or not creds.valid:
# if creds and creds.expired and creds.refresh_token:
# creds.refresh(Request())
# else:
# flow = InstalledAppFlow.from_client_secrets_file(
# os.getenv("GOOGLE_ACCOUNT_FILE"),
# SCOPES
# )
# creds = flow.run_local_server(port=0)
# with open("token.json", "w") as token:
# token.write(creds.to_json())
# return creds

def get_folder_id(service, folder_name):
"""Get the ID of a folder by name."""
Expand Down Expand Up @@ -222,4 +222,4 @@ def main():


if __name__ == "__main__":
files = main()
files = main() #not imported/used elsewhere (ask if it used in any script)
2 changes: 1 addition & 1 deletion service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def generate_timestamp_json(translation, summary, detected_language=None):
}

@api_version(1)
@app.post("/upload-audio")
@app.post("/upload-audio") #2 definations of upload_audio , we can keep the latest version or which is getting used and remove another
async def upload_audio(body: Body):
try:
if body.audio_file_link == "":
Expand Down
2 changes: 1 addition & 1 deletion service/surv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


#SARVAM_API_KEY="sk_lz33toms_amJdXnvyWxlBQIs4OPue1yexi"
SARVAM_API_KEY="sk_t7fvsjjb_7JsD5ZXGrEhHqjUtAQSFsCxB"
SARVAM_API_KEY="sk_t7fvsjjb_7JsD5ZXGrEhHqjUtAQSFsCxB" #should not harcode an API key in code
client = SarvamAI(
api_subscription_key=SARVAM_API_KEY,
)
Expand Down
2 changes: 1 addition & 1 deletion service/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

def generate_timestamp_json(translation,summary,detected_language):
def generate_timestamp_json(translation,summary,detected_language): #same name function is used in main.py , can we write logic in such a way that only one function used everywhere
segs = []
seg = {}
segments = translation["segments"]
Expand Down