Skip to content

Commit

Permalink
type corrected
Browse files Browse the repository at this point in the history
some dead code removed
  • Loading branch information
rebeccali04 committed Apr 5, 2024
1 parent 9d4ece9 commit 642cd3c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def get_translation(post: str) -> str:



def get_language(post: str) -> bool:
# ----------------- DO NOT MODIFY ------------------ #
def get_language(post: str) -> str:
model = genai.GenerativeModel(model_name="gemini-pro")
parameters = {
"temperature": 0.7, # Temperature controls the degree of randomness in token selection.
Expand All @@ -39,17 +38,14 @@ def get_language(post: str) -> bool:
context = f"Context = 'I want to know what language the prompt is', prompt = '{post}'"
response = model.generate_content(context+post)
# classification = "non-English" if "English" not in response.text else "English"
classification = ("english" in response.text) or ("English" in response.text)
return response.text#debug
return classification

def query_llm(post: str) -> tuple[bool, str]:
language = get_language(post)

if language!='English':
translated_post = get_translation(post)
else:
# translated_post = post
translated_post = post
is_English = ("english" in language) or ("English" in language)
return is_English, translated_post
Expand Down

0 comments on commit 642cd3c

Please sign in to comment.