mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
fix: linter
This commit is contained in:
parent
b5fb55069b
commit
2f45673694
@ -17,10 +17,10 @@ class BannerApi(Resource):
|
|||||||
|
|
||||||
# Build base query for enabled banners
|
# Build base query for enabled banners
|
||||||
base_query = db.session.query(ExporleBanner).where(ExporleBanner.status == "enabled")
|
base_query = db.session.query(ExporleBanner).where(ExporleBanner.status == "enabled")
|
||||||
|
|
||||||
# Try to get banners in the requested language
|
# Try to get banners in the requested language
|
||||||
banners = base_query.where(ExporleBanner.language == language).order_by(ExporleBanner.sort).all()
|
banners = base_query.where(ExporleBanner.language == language).order_by(ExporleBanner.sort).all()
|
||||||
|
|
||||||
# Fallback to en-US if no banners found and language is not en-US
|
# Fallback to en-US if no banners found and language is not en-US
|
||||||
if not banners and language != "en-US":
|
if not banners and language != "en-US":
|
||||||
banners = base_query.where(ExporleBanner.language == "en-US").order_by(ExporleBanner.sort).all()
|
banners = base_query.where(ExporleBanner.language == "en-US").order_by(ExporleBanner.sort).all()
|
||||||
|
|||||||
@ -156,11 +156,11 @@ class TrialChatApi(TrialAppResource):
|
|||||||
try:
|
try:
|
||||||
if not isinstance(current_user, Account):
|
if not isinstance(current_user, Account):
|
||||||
raise ValueError("current_user must be an Account instance")
|
raise ValueError("current_user must be an Account instance")
|
||||||
|
|
||||||
# Get IDs before they might be detached from session
|
# Get IDs before they might be detached from session
|
||||||
app_id = app_model.id
|
app_id = app_model.id
|
||||||
user_id = current_user.id
|
user_id = current_user.id
|
||||||
|
|
||||||
response = AppGenerateService.generate(
|
response = AppGenerateService.generate(
|
||||||
app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=True
|
app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=True
|
||||||
)
|
)
|
||||||
@ -237,11 +237,11 @@ class TrialChatAudioApi(TrialAppResource):
|
|||||||
try:
|
try:
|
||||||
if not isinstance(current_user, Account):
|
if not isinstance(current_user, Account):
|
||||||
raise ValueError("current_user must be an Account instance")
|
raise ValueError("current_user must be an Account instance")
|
||||||
|
|
||||||
# Get IDs before they might be detached from session
|
# Get IDs before they might be detached from session
|
||||||
app_id = app_model.id
|
app_id = app_model.id
|
||||||
user_id = current_user.id
|
user_id = current_user.id
|
||||||
|
|
||||||
response = AudioService.transcript_asr(app_model=app_model, file=file, end_user=None)
|
response = AudioService.transcript_asr(app_model=app_model, file=file, end_user=None)
|
||||||
RecommendedAppService.add_trial_app_record(app_id, user_id)
|
RecommendedAppService.add_trial_app_record(app_id, user_id)
|
||||||
return response
|
return response
|
||||||
@ -288,11 +288,11 @@ class TrialChatTextApi(TrialAppResource):
|
|||||||
voice = args.get("voice", None)
|
voice = args.get("voice", None)
|
||||||
if not isinstance(current_user, Account):
|
if not isinstance(current_user, Account):
|
||||||
raise ValueError("current_user must be an Account instance")
|
raise ValueError("current_user must be an Account instance")
|
||||||
|
|
||||||
# Get IDs before they might be detached from session
|
# Get IDs before they might be detached from session
|
||||||
app_id = app_model.id
|
app_id = app_model.id
|
||||||
user_id = current_user.id
|
user_id = current_user.id
|
||||||
|
|
||||||
response = AudioService.transcript_tts(app_model=app_model, text=text, voice=voice, message_id=message_id)
|
response = AudioService.transcript_tts(app_model=app_model, text=text, voice=voice, message_id=message_id)
|
||||||
RecommendedAppService.add_trial_app_record(app_id, user_id)
|
RecommendedAppService.add_trial_app_record(app_id, user_id)
|
||||||
return response
|
return response
|
||||||
@ -343,11 +343,11 @@ class TrialCompletionApi(TrialAppResource):
|
|||||||
try:
|
try:
|
||||||
if not isinstance(current_user, Account):
|
if not isinstance(current_user, Account):
|
||||||
raise ValueError("current_user must be an Account instance")
|
raise ValueError("current_user must be an Account instance")
|
||||||
|
|
||||||
# Get IDs before they might be detached from session
|
# Get IDs before they might be detached from session
|
||||||
app_id = app_model.id
|
app_id = app_model.id
|
||||||
user_id = current_user.id
|
user_id = current_user.id
|
||||||
|
|
||||||
response = AppGenerateService.generate(
|
response = AppGenerateService.generate(
|
||||||
app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=streaming
|
app_model=app_model, user=current_user, args=args, invoke_from=InvokeFrom.EXPLORE, streaming=streaming
|
||||||
)
|
)
|
||||||
|
|||||||
@ -87,6 +87,8 @@ def trial_app_required(view: Callable[Concatenate[App, P], R] | None = None):
|
|||||||
if app is None:
|
if app is None:
|
||||||
raise TrialAppNotAllowed()
|
raise TrialAppNotAllowed()
|
||||||
|
|
||||||
|
assert isinstance(current_user, Account)
|
||||||
|
|
||||||
account_trial_app_record = (
|
account_trial_app_record = (
|
||||||
db.session.query(AccountTrialAppRecord)
|
db.session.query(AccountTrialAppRecord)
|
||||||
.where(AccountTrialAppRecord.account_id == current_user.id, AccountTrialAppRecord.app_id == app_id)
|
.where(AccountTrialAppRecord.account_id == current_user.id, AccountTrialAppRecord.app_id == app_id)
|
||||||
|
|||||||
@ -60,10 +60,11 @@ class RecommendedAppService:
|
|||||||
:param app_id: app id
|
:param app_id: app id
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
account_trial_app_record = db.session.query(AccountTrialAppRecord).where(
|
account_trial_app_record = (
|
||||||
AccountTrialAppRecord.app_id == app_id,
|
db.session.query(AccountTrialAppRecord)
|
||||||
AccountTrialAppRecord.account_id == account_id
|
.where(AccountTrialAppRecord.app_id == app_id, AccountTrialAppRecord.account_id == account_id)
|
||||||
).first()
|
.first()
|
||||||
|
)
|
||||||
if account_trial_app_record:
|
if account_trial_app_record:
|
||||||
account_trial_app_record.count += 1
|
account_trial_app_record.count += 1
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user