Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
fix: conditions in core
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdanielpark committed Dec 27, 2023
1 parent b98554c commit 04496f6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bardapi/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,19 +674,21 @@ def ask_about_image(
translator_to_eng = GoogleTranslator(source="auto", target="en")

# [Optional] Set language
if (
if self.language is None and lang is None:
translated_input_text = input_text
elif (
(self.language is not None or lang is not None)
and self.language not in ALLOWED_LANGUAGES
and self.google_translator_api_key is None
):
translator_to_eng = GoogleTranslator(source="auto", target="en")
transl_text = translator_to_eng.translate(input_text)
translated_input_text = translator_to_eng.translate(input_text)
elif (
(self.language is not None or lang is not None)
and self.language not in ALLOWED_LANGUAGES
and self.google_translator_api_key is not None
):
transl_text = google_official_translator.translate(
translated_input_text = google_official_translator.translate(
input_text, target_language="en"
)
elif (
Expand All @@ -695,15 +697,16 @@ def ask_about_image(
and self.google_translator_api_key is None
):
translator_to_eng = GoogleTranslator(source="auto", target="en")
transl_text = translator_to_eng.translate(input_text)
translated_input_text = translator_to_eng.translate(input_text)


# Supported format: jpeg, png, webp
image_url = upload_image(image)

input_data_struct = [
None,
[
[transl_text, 0, None, [[[image_url, 1], "uploaded_photo.jpg"]]],
[translated_input_text, 0, None, [[[image_url, 1], "uploaded_photo.jpg"]]],
[lang if lang is not None else self.language],
["", "", ""],
"", # Unknown random string value (1000 characters +)
Expand Down

0 comments on commit 04496f6

Please sign in to comment.