diff --git a/app/app.py b/app/app.py index 3956de7..0107536 100644 --- a/app/app.py +++ b/app/app.py @@ -132,6 +132,7 @@ def export_txt(strings): else: return gr.update(visible=False) + def switch(source_lang, source_text, target_lang, output_final): if output_final: return ( @@ -314,9 +315,7 @@ def close_btn_hide(output_diff): with gr.Column(scale=4): source_text = gr.Textbox( label="Source Text", - value="How we live is so different from how we ought to live that he who studies " - + "what ought to be done rather than what is done will learn the way to his downfall " - + "rather than to his preservation.", + value="If one advances confidently in the direction of his dreams, and endeavors to live the life which he has imagined, he will meet with a success unexpected in common hours.", lines=12, ) with gr.Tab("Final"): diff --git a/app/patch.py b/app/patch.py index d6af9a7..89fdd43 100644 --- a/app/patch.py +++ b/app/patch.py @@ -15,7 +15,6 @@ # Hide js_mode in UI now, update in plan. JS_MODE = False ENDPOINT = "" -client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY")) # Add your LLMs here @@ -35,26 +34,29 @@ def model_load( TEMPERATURE = temperature JS_MODE = js_mode - if endpoint == "Groq": - client = openai.OpenAI( - api_key=api_key if api_key else os.getenv("GROQ_API_KEY"), - base_url="https://api.groq.com/openai/v1", - ) - elif endpoint == "TogetherAI": - client = openai.OpenAI( - api_key=api_key if api_key else os.getenv("TOGETHER_API_KEY"), - base_url="https://api.together.xyz/v1", - ) - elif endpoint == "CUSTOM": - client = openai.OpenAI(api_key=api_key, base_url=base_url) - elif endpoint == "Ollama": - client = openai.OpenAI( - api_key="ollama", base_url="http://localhost:11434/v1" - ) - else: - client = openai.OpenAI( - api_key=api_key if api_key else os.getenv("OPENAI_API_KEY") - ) + match endpoint: + case "OpenAI": + client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY")) + case "Groq": + client = openai.OpenAI( + api_key=api_key if api_key else os.getenv("GROQ_API_KEY"), + base_url="https://api.groq.com/openai/v1", + ) + case "TogetherAI": + client = openai.OpenAI( + api_key=api_key if api_key else os.getenv("TOGETHER_API_KEY"), + base_url="https://api.together.xyz/v1", + ) + case "CUSTOM": + client = openai.OpenAI(api_key=api_key, base_url=base_url) + case "Ollama": + client = openai.OpenAI( + api_key="ollama", base_url="http://localhost:11434/v1" + ) + case _: + client = openai.OpenAI( + api_key=api_key if api_key else os.getenv("OPENAI_API_KEY") + ) def rate_limit(get_max_per_minute): diff --git a/pyproject.toml b/pyproject.toml index 7629d40..26fb0db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,9 +6,7 @@ authors = ["Andrew Ng "] license = "MIT" readme = "README.md" package-mode = true -packages = [ - { include = "translation_agent", from = "src" }, - ] +packages = [{ include = "translation_agent", from = "src" }] repository = "https://github.com/andrewyng/translation-agent" keywords = ["translation", "agents", "LLM", "machine translation"]