Skip to content

Commit

Permalink
prompt engineering on get language
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccali04 committed Apr 5, 2024
1 parent 0b9f7da commit cad785c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
def get_translation(post: str) -> str:
# ----------------- DO NOT MODIFY ------------------ #
context = ("Context = The following text is in a foreign language and needs to be translated into English"
+"please respond only in english. "
+"please translate this to English. "
+ f"Prompt: {post}")
model = genai.GenerativeModel(model_name="gemini-pro")
parameters = {
"temperature": 0.7, # Temperature controls the degree of randomness in token selection.
"max_output_tokens": 256, # Token limit determines the maximum amount of text output.
}

response = model.generate_content(context+post)
response = model.generate_content(context)
return response.text



context = "The following text is not in English and needs to be classified as non-English Text"

def get_language(post: str) -> str:
# ----------------- DO NOT MODIFY ------------------ #
model = genai.GenerativeModel(model_name="gemini-pro")
Expand All @@ -36,8 +36,7 @@ def get_language(post: str) -> str:
"max_output_tokens": 256, # Token limit determines the maximum amount of text output.
}

#mock the init part of the start too
#sending the authentication part should be a no op
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"
return response.text#debug
Expand Down

0 comments on commit cad785c

Please sign in to comment.