🔧 chore(llms.py): add format_openai_field method to format OpenAI field display names

The `format_openai_field` method formats the display name of fields that contain the string "openai" in their name. It capitalizes the first letter of "OpenAI", replaces underscores with spaces, and replaces "Api" with "API". This improves the readability and consistency of the display names of OpenAI fields.
This commit is contained in:
Gabriel Almeida 2023-05-27 17:58:00 -03:00
commit 6f8b434f68

View file

@ -5,6 +5,13 @@ from langflow.template.frontend_node.base import FrontendNode
class LLMFrontendNode(FrontendNode):
@staticmethod
def format_openai_field(field: TemplateField):
if "openai" in field.name.lower():
field.display_name = (
field.name.title().replace("Openai", "OpenAI").replace("_", " ")
).replace("Api", "API")
@staticmethod
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
display_names_dict = {
@ -39,3 +46,5 @@ class LLMFrontendNode(FrontendNode):
elif field.name in ["model_name", "temperature"]:
field.advanced = False
field.show = True
LLMFrontendNode.format_openai_field(field)