Skip to content

Commit

Permalink
Merge pull request #12 from RongYYYY/final-touches
Browse files Browse the repository at this point in the history
cleaning up code
  • Loading branch information
ogometz authored Nov 16, 2024
2 parents 2b53606 + 198975a commit 0a62eef
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
azure_endpoint="https://apirecitation.openai.azure.com" # Replace with your Azure endpoint
)

# Make a request to your Azure OpenAI model
response = client.chat.completions.create(
model="gpt-4o-mini", # This should match your deployment name in Azure
messages=[
{
"role": "user",
"content": "What is the future of artificial intelligence?"
}
]
)


def get_language(post: str) -> str:
context = f"I'm trying to translate some text, only return the language it is written in and nothing else. What is the language this text: {post} is written in."
Expand Down Expand Up @@ -79,12 +68,11 @@ def get_translation(post: str) -> str:
def translate_content(content: str) -> tuple[bool, str]:
try:
is_eng = get_language(content)
is_translated = get_translation(content)
if (is_translated is None or
not isinstance(is_translated, str) or
is_translated == "N/A" or
len(is_translated) <= 0 or
is_translated == "I don't understand your request"):
if (is_eng is None or
not isinstance(is_eng, str) or
is_eng == "N/A" or
len(is_eng) <= 0 or
is_eng == "I don't understand your request"):
return False, "There was an error translating the text"

if is_eng == "English":
Expand Down

0 comments on commit 0a62eef

Please sign in to comment.