feat: add chat-gpt
This commit is contained in:
parent
c83d548531
commit
38141943f6
7 changed files with 21 additions and 10 deletions
6
src/backend/langflow/interface/custom_lists.py
Normal file
6
src/backend/langflow/interface/custom_lists.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from langchain import llms
|
||||
from langchain.llms.openai import OpenAIChat
|
||||
|
||||
|
||||
llm_type_to_cls_dict = llms.type_to_cls_dict
|
||||
llm_type_to_cls_dict["openai-chat"] = OpenAIChat
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
from langchain import chains, agents, prompts, llms
|
||||
from langchain import chains, agents, prompts
|
||||
from langflow.interface.custom_lists import llm_type_to_cls_dict
|
||||
from langflow.custom import customs
|
||||
from langflow.utils import util, allowed_components
|
||||
from langchain.agents.load_tools import get_all_tool_names
|
||||
|
|
@ -55,7 +56,7 @@ def list_llms():
|
|||
"""List all llm types"""
|
||||
return [
|
||||
llm.__name__
|
||||
for llm in llms.type_to_cls_dict.values()
|
||||
for llm in llm_type_to_cls_dict.values()
|
||||
if llm.__name__ in allowed_components.LLMS
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from typing import Dict, Any # noqa: F401
|
||||
from langchain import agents, chains, llms, prompts
|
||||
from langchain import agents, chains, prompts
|
||||
from langflow.interface.custom_lists import llm_type_to_cls_dict
|
||||
from langchain.agents.load_tools import (
|
||||
_BASE_TOOLS,
|
||||
_EXTRA_LLM_TOOLS,
|
||||
|
|
@ -56,7 +57,7 @@ def get_prompt_signature(name: str):
|
|||
def get_llm_signature(name: str):
|
||||
"""Get the signature of an llm."""
|
||||
try:
|
||||
return util.build_template_from_class(name, llms.type_to_cls_dict)
|
||||
return util.build_template_from_class(name, llm_type_to_cls_dict)
|
||||
except ValueError as exc:
|
||||
raise ValueError("LLM not found") from exc
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ AGENTS = ["ZeroShotAgent"]
|
|||
|
||||
PROMPTS = ["PromptTemplate", "FewShotPromptTemplate"]
|
||||
|
||||
LLMS = ["OpenAI"]
|
||||
LLMS = ["OpenAI", "OpenAIChat"]
|
||||
|
||||
TOOLS = ["Search", "PAL-MATH", "Calculator", "Serper Search"]
|
||||
|
|
|
|||
|
|
@ -297,6 +297,8 @@ def format_dict(d, name: Optional[str] = None):
|
|||
# Add options to openai
|
||||
if name == "OpenAI" and key == "model_name":
|
||||
value["options"] = ["text-davinci-003", "text-davinci-002"]
|
||||
elif name == "OpenAIChat" and key == "model_name":
|
||||
value["options"] = ["gpt-3.5-turbo", "gpt-4"]
|
||||
|
||||
return d
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue