🔧 chore(base.py, constants.py, llms.py): add info field to TemplateField and OPENAI_API_BASE_INFO constant
The `info` field is added to the `TemplateField` class to provide additional information about the field. The `OPENAI_API_BASE_INFO` constant is added to the `constants.py` file to provide information about the base URL of the OpenAI API and how it can be changed to use other APIs like Prem and LocalAI. The `info` field is set to `OPENAI_API_BASE_INFO` for the `openai_api_base` field in the `LLMFrontendNode` class in `llms.py`.
This commit is contained in:
parent
87af22d059
commit
415bee7384
3 changed files with 15 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ class TemplateFieldCreator(BaseModel, ABC):
|
||||||
name: str = ""
|
name: str = ""
|
||||||
display_name: Optional[str] = None
|
display_name: Optional[str] = None
|
||||||
advanced: bool = False
|
advanced: bool = False
|
||||||
|
info: Optional[str] = ""
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
result = self.dict()
|
result = self.dict()
|
||||||
|
|
|
||||||
|
|
@ -32,3 +32,13 @@ You are a good listener and you can talk about anything.
|
||||||
HUMAN_PROMPT = "{input}"
|
HUMAN_PROMPT = "{input}"
|
||||||
|
|
||||||
QA_CHAIN_TYPES = ["stuff", "map_reduce", "map_rerank", "refine"]
|
QA_CHAIN_TYPES = ["stuff", "map_reduce", "map_rerank", "refine"]
|
||||||
|
|
||||||
|
|
||||||
|
# This variable is used to tell the user
|
||||||
|
# that it can be changed to use other APIs
|
||||||
|
# like Prem and LocalAI
|
||||||
|
OPENAI_API_BASE_INFO = """
|
||||||
|
The base URL of the OpenAI API. Defaults to https://api.openai.com/v1.
|
||||||
|
|
||||||
|
You can change this to use other APIs like Prem and LocalAI.
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ from typing import Optional
|
||||||
|
|
||||||
from langflow.template.field.base import TemplateField
|
from langflow.template.field.base import TemplateField
|
||||||
from langflow.template.frontend_node.base import FrontendNode
|
from langflow.template.frontend_node.base import FrontendNode
|
||||||
|
from langflow.template.frontend_node.constants import OPENAI_API_BASE_INFO
|
||||||
|
|
||||||
|
|
||||||
class LLMFrontendNode(FrontendNode):
|
class LLMFrontendNode(FrontendNode):
|
||||||
|
|
@ -15,6 +16,9 @@ class LLMFrontendNode(FrontendNode):
|
||||||
if "key" not in field.name.lower() and "token" not in field.name.lower():
|
if "key" not in field.name.lower() and "token" not in field.name.lower():
|
||||||
field.password = False
|
field.password = False
|
||||||
|
|
||||||
|
if field.name == "openai_api_base":
|
||||||
|
field.info = OPENAI_API_BASE_INFO
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_azure_field(field: TemplateField):
|
def format_azure_field(field: TemplateField):
|
||||||
if field.name == "model_name":
|
if field.name == "model_name":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue