Skip to content

Commit

Permalink
Merge pull request #6094 from ProcessMaker/FOUR-13273
Browse files Browse the repository at this point in the history
[FOUR-13273] Update translation script
  • Loading branch information
ryancooley authored Jan 25, 2024
2 parents c2be8cc + e668a27 commit 5b6259f
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/scripts/translate.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import json
import os
import openai
from openai import OpenAI

client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
organization=os.environ["OPENAI_ORG"]
)
import sys
import time

openai.api_key = os.environ["OPENAI_API_KEY"]
openai.organization = os.environ["OPENAI_ORG"]

# Supported languages dictionary
languages = {
'es': 'Spanish',
Expand Down Expand Up @@ -50,19 +53,17 @@ def main():
while retry_count < max_retries:
try:
start_time = time.time()
response=openai.ChatCompletion.create(
model='gpt-4',
messages=[
{
"role": "user",
"content": prompt
}
],
temperature=0.3,
max_tokens=500,
n=1,
stop=None
)
response=client.chat.completions.create(model='gpt-4',
messages=[
{
"role": "user",
"content": prompt
}
],
temperature=0.3,
max_tokens=500,
n=1,
stop=None)
elapsed_time = time.time() - start_time
if elapsed_time < timeout:
translated_data[key] = response.choices[0].message.content.strip('"')
Expand Down

0 comments on commit 5b6259f

Please sign in to comment.