Update input variable names in build functions
This commit is contained in:
parent
f6e7fa6374
commit
e2e6f80461
23 changed files with 62 additions and 52 deletions
|
|
@ -23,7 +23,7 @@ class ConversationChainComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
memory: Optional[BaseMemory] = None,
|
memory: Optional[BaseMemory] = None,
|
||||||
) -> Text:
|
) -> Text:
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class LLMCheckerChainComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
) -> Text:
|
) -> Text:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class LLMMathChainComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: Text,
|
input_value: Text,
|
||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
llm_chain: LLMChain,
|
llm_chain: LLMChain,
|
||||||
input_key: str = "question",
|
input_key: str = "question",
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class RetrievalQAComponent(CustomComponent):
|
||||||
self,
|
self,
|
||||||
combine_documents_chain: BaseCombineDocumentsChain,
|
combine_documents_chain: BaseCombineDocumentsChain,
|
||||||
retriever: BaseRetriever,
|
retriever: BaseRetriever,
|
||||||
inputs: str = "",
|
input_value: str = "",
|
||||||
memory: Optional[BaseMemory] = None,
|
memory: Optional[BaseMemory] = None,
|
||||||
input_key: str = "query",
|
input_key: str = "query",
|
||||||
output_key: str = "result",
|
output_key: str = "result",
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
retriever: BaseRetriever,
|
retriever: BaseRetriever,
|
||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
chain_type: str,
|
chain_type: str,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class SQLGeneratorComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: Text,
|
input_value: Text,
|
||||||
db: SQLDatabase,
|
db: SQLDatabase,
|
||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
top_k: int = 5,
|
top_k: int = 5,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class ChatInput(CustomComponent):
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"message": {
|
"input_value": {
|
||||||
"input_types": ["Text"],
|
"input_types": ["Text"],
|
||||||
"display_name": "Message",
|
"display_name": "Message",
|
||||||
"multiline": True,
|
"multiline": True,
|
||||||
|
|
@ -35,26 +35,26 @@ class ChatInput(CustomComponent):
|
||||||
self,
|
self,
|
||||||
sender: Optional[str] = "User",
|
sender: Optional[str] = "User",
|
||||||
sender_name: Optional[str] = "User",
|
sender_name: Optional[str] = "User",
|
||||||
message: Optional[str] = None,
|
input_value: Optional[str] = None,
|
||||||
session_id: Optional[str] = None,
|
session_id: Optional[str] = None,
|
||||||
return_record: Optional[bool] = False,
|
return_record: Optional[bool] = False,
|
||||||
) -> Union[Text, Record]:
|
) -> Union[Text, Record]:
|
||||||
if return_record:
|
if return_record:
|
||||||
if isinstance(message, Record):
|
if isinstance(input_value, Record):
|
||||||
# Update the data of the record
|
# Update the data of the record
|
||||||
message.data["sender"] = sender
|
input_value.data["sender"] = sender
|
||||||
message.data["sender_name"] = sender_name
|
input_value.data["sender_name"] = sender_name
|
||||||
message.data["session_id"] = session_id
|
input_value.data["session_id"] = session_id
|
||||||
else:
|
else:
|
||||||
message = Record(
|
input_value = Record(
|
||||||
text=message,
|
text=input_value,
|
||||||
data={
|
data={
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
"sender_name": sender_name,
|
"sender_name": sender_name,
|
||||||
"session_id": session_id,
|
"session_id": session_id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if not message:
|
if not input_value:
|
||||||
message = ""
|
input_value = ""
|
||||||
self.status = message
|
self.status = input_value
|
||||||
return message
|
return input_value
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class ChatOutput(CustomComponent):
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"message": {"input_types": ["Text"], "display_name": "Message"},
|
"input_value": {"input_types": ["Text"], "display_name": "Message"},
|
||||||
"sender": {
|
"sender": {
|
||||||
"options": ["Machine", "User"],
|
"options": ["Machine", "User"],
|
||||||
"display_name": "Sender Type",
|
"display_name": "Sender Type",
|
||||||
|
|
@ -39,25 +39,25 @@ class ChatOutput(CustomComponent):
|
||||||
sender: Optional[str] = "Machine",
|
sender: Optional[str] = "Machine",
|
||||||
sender_name: Optional[str] = "AI",
|
sender_name: Optional[str] = "AI",
|
||||||
session_id: Optional[str] = None,
|
session_id: Optional[str] = None,
|
||||||
message: Optional[str] = None,
|
input_value: Optional[str] = None,
|
||||||
return_record: Optional[bool] = False,
|
return_record: Optional[bool] = False,
|
||||||
) -> Union[Text, Record]:
|
) -> Union[Text, Record]:
|
||||||
if return_record:
|
if return_record:
|
||||||
if isinstance(message, Record):
|
if isinstance(input_value, Record):
|
||||||
# Update the data of the record
|
# Update the data of the record
|
||||||
message.data["sender"] = sender
|
input_value.data["sender"] = sender
|
||||||
message.data["sender_name"] = sender_name
|
input_value.data["sender_name"] = sender_name
|
||||||
message.data["session_id"] = session_id
|
input_value.data["session_id"] = session_id
|
||||||
else:
|
else:
|
||||||
message = Record(
|
input_value = Record(
|
||||||
text=message,
|
text=input_value,
|
||||||
data={
|
data={
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
"sender_name": sender_name,
|
"sender_name": sender_name,
|
||||||
"session_id": session_id,
|
"session_id": session_id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if not message:
|
if not input_value:
|
||||||
message = ""
|
input_value = ""
|
||||||
self.status = message
|
self.status = input_value
|
||||||
return message
|
return input_value
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class AmazonBedrockComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
model_id: str = "anthropic.claude-instant-v1",
|
model_id: str = "anthropic.claude-instant-v1",
|
||||||
credentials_profile_name: Optional[str] = None,
|
credentials_profile_name: Optional[str] = None,
|
||||||
region_name: Optional[str] = None,
|
region_name: Optional[str] = None,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,9 @@ from langflow.field_typing import Text
|
||||||
|
|
||||||
class AnthropicLLM(CustomComponent):
|
class AnthropicLLM(CustomComponent):
|
||||||
display_name: str = "AnthropicModel"
|
display_name: str = "AnthropicModel"
|
||||||
description: str = "Generate text using Anthropic Chat&Completion large language models."
|
description: str = (
|
||||||
|
"Generate text using Anthropic Chat&Completion large language models."
|
||||||
|
)
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
|
|
@ -53,7 +55,7 @@ class AnthropicLLM(CustomComponent):
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
model: str,
|
model: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
anthropic_api_key: Optional[str] = None,
|
anthropic_api_key: Optional[str] = None,
|
||||||
max_tokens: Optional[int] = None,
|
max_tokens: Optional[int] = None,
|
||||||
temperature: Optional[float] = None,
|
temperature: Optional[float] = None,
|
||||||
|
|
@ -66,7 +68,9 @@ class AnthropicLLM(CustomComponent):
|
||||||
try:
|
try:
|
||||||
output = ChatAnthropic(
|
output = ChatAnthropic(
|
||||||
model_name=model,
|
model_name=model,
|
||||||
anthropic_api_key=(SecretStr(anthropic_api_key) if anthropic_api_key else None),
|
anthropic_api_key=(
|
||||||
|
SecretStr(anthropic_api_key) if anthropic_api_key else None
|
||||||
|
),
|
||||||
max_tokens_to_sample=max_tokens, # type: ignore
|
max_tokens_to_sample=max_tokens, # type: ignore
|
||||||
temperature=temperature,
|
temperature=temperature,
|
||||||
anthropic_api_url=api_endpoint,
|
anthropic_api_url=api_endpoint,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,9 @@ from langflow import CustomComponent
|
||||||
class AzureChatOpenAIComponent(CustomComponent):
|
class AzureChatOpenAIComponent(CustomComponent):
|
||||||
display_name: str = "AzureOpenAI Model"
|
display_name: str = "AzureOpenAI Model"
|
||||||
description: str = "Generate text using LLM model from Azure OpenAI."
|
description: str = "Generate text using LLM model from Azure OpenAI."
|
||||||
documentation: str = "https://python.langchain.com/docs/integrations/llms/azure_openai"
|
documentation: str = (
|
||||||
|
"https://python.langchain.com/docs/integrations/llms/azure_openai"
|
||||||
|
)
|
||||||
beta = False
|
beta = False
|
||||||
|
|
||||||
AZURE_OPENAI_MODELS = [
|
AZURE_OPENAI_MODELS = [
|
||||||
|
|
@ -78,7 +80,7 @@ class AzureChatOpenAIComponent(CustomComponent):
|
||||||
self,
|
self,
|
||||||
model: str,
|
model: str,
|
||||||
azure_endpoint: str,
|
azure_endpoint: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
azure_deployment: str,
|
azure_deployment: str,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
api_version: str,
|
api_version: str,
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ class QianfanChatEndpointComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
model: str = "ERNIE-Bot-turbo",
|
model: str = "ERNIE-Bot-turbo",
|
||||||
qianfan_ak: Optional[str] = None,
|
qianfan_ak: Optional[str] = None,
|
||||||
qianfan_sk: Optional[str] = None,
|
qianfan_sk: Optional[str] = None,
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,13 @@ class CTransformersComponent(CustomComponent):
|
||||||
self,
|
self,
|
||||||
model: str,
|
model: str,
|
||||||
model_file: str,
|
model_file: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
model_type: str,
|
model_type: str,
|
||||||
config: Optional[Dict] = None,
|
config: Optional[Dict] = None,
|
||||||
) -> Text:
|
) -> Text:
|
||||||
output = CTransformers(model=model, model_file=model_file, model_type=model_type, config=config)
|
output = CTransformers(
|
||||||
|
model=model, model_file=model_file, model_type=model_type, config=config
|
||||||
|
)
|
||||||
message = output.invoke(inputs)
|
message = output.invoke(inputs)
|
||||||
result = message.content if hasattr(message, "content") else message
|
result = message.content if hasattr(message, "content") else message
|
||||||
self.status = result
|
self.status = result
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class CohereComponent(CustomComponent):
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
cohere_api_key: str,
|
cohere_api_key: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
max_tokens: int = 256,
|
max_tokens: int = 256,
|
||||||
temperature: float = 0.75,
|
temperature: float = 0.75,
|
||||||
) -> Text:
|
) -> Text:
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class GoogleGenerativeAIComponent(CustomComponent):
|
||||||
self,
|
self,
|
||||||
google_api_key: str,
|
google_api_key: str,
|
||||||
model: str,
|
model: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
max_output_tokens: Optional[int] = None,
|
max_output_tokens: Optional[int] = None,
|
||||||
temperature: float = 0.1,
|
temperature: float = 0.1,
|
||||||
top_k: Optional[int] = None,
|
top_k: Optional[int] = None,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from langchain_community.chat_models.huggingface import ChatHuggingFace
|
||||||
from langchain_community.llms.huggingface_endpoint import HuggingFaceEndpoint
|
from langchain_community.llms.huggingface_endpoint import HuggingFaceEndpoint
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow import CustomComponent
|
||||||
|
|
||||||
from langflow.field_typing import Text
|
from langflow.field_typing import Text
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,7 +29,7 @@ class HuggingFaceEndpointsComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
endpoint_url: str,
|
endpoint_url: str,
|
||||||
task: str = "text2text-generation",
|
task: str = "text2text-generation",
|
||||||
huggingfacehub_api_token: Optional[str] = None,
|
huggingfacehub_api_token: Optional[str] = None,
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class LlamaCppComponent(CustomComponent):
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
model_path: str,
|
model_path: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
grammar: Optional[str] = None,
|
grammar: Optional[str] = None,
|
||||||
cache: Optional[bool] = None,
|
cache: Optional[bool] = None,
|
||||||
client: Optional[Any] = None,
|
client: Optional[Any] = None,
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ class ChatOllamaComponent(CustomComponent):
|
||||||
self,
|
self,
|
||||||
base_url: Optional[str],
|
base_url: Optional[str],
|
||||||
model: str,
|
model: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
mirostat: Optional[str],
|
mirostat: Optional[str],
|
||||||
mirostat_eta: Optional[float] = None,
|
mirostat_eta: Optional[float] = None,
|
||||||
mirostat_tau: Optional[float] = None,
|
mirostat_tau: Optional[float] = None,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from langchain_openai import ChatOpenAI
|
from langchain_openai import ChatOpenAI
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow import CustomComponent
|
||||||
from langflow.field_typing import NestedDict, Text
|
from langflow.field_typing import NestedDict, Text
|
||||||
|
|
||||||
|
|
@ -60,7 +61,7 @@ class OpenAIModelComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: Text,
|
input_value: Text,
|
||||||
max_tokens: Optional[int] = 256,
|
max_tokens: Optional[int] = 256,
|
||||||
model_kwargs: NestedDict = {},
|
model_kwargs: NestedDict = {},
|
||||||
model_name: str = "gpt-4-1106-preview",
|
model_name: str = "gpt-4-1106-preview",
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class ChatVertexAIComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
credentials: Optional[str],
|
credentials: Optional[str],
|
||||||
project: str,
|
project: str,
|
||||||
examples: Optional[List[BaseMessage]] = [],
|
examples: Optional[List[BaseMessage]] = [],
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class RunnableExecComponent(CustomComponent):
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
input_key: str,
|
input_key: str,
|
||||||
inputs: str,
|
input_value: str,
|
||||||
runnable: Runnable,
|
runnable: Runnable,
|
||||||
output_key: str = "output",
|
output_key: str = "output",
|
||||||
) -> Text:
|
) -> Text:
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ from typing import List, Optional
|
||||||
|
|
||||||
import chromadb # type: ignore
|
import chromadb # type: ignore
|
||||||
from langchain_community.vectorstores.chroma import Chroma
|
from langchain_community.vectorstores.chroma import Chroma
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow import CustomComponent
|
||||||
from langflow.field_typing import Embeddings, Text
|
from langflow.field_typing import Embeddings, Text
|
||||||
from langflow.schema import Record, docs_to_records
|
from langflow.schema import Record, docs_to_records
|
||||||
|
|
@ -57,7 +58,7 @@ class ChromaSearchComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
inputs: Text,
|
input_value: Text,
|
||||||
search_type: str,
|
search_type: str,
|
||||||
collection_name: str,
|
collection_name: str,
|
||||||
embedding: Embeddings,
|
embedding: Embeddings,
|
||||||
|
|
@ -92,7 +93,8 @@ class ChromaSearchComponent(CustomComponent):
|
||||||
|
|
||||||
if chroma_server_host is not None:
|
if chroma_server_host is not None:
|
||||||
chroma_settings = chromadb.config.Settings(
|
chroma_settings = chromadb.config.Settings(
|
||||||
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins or None,
|
chroma_server_cors_allow_origins=chroma_server_cors_allow_origins
|
||||||
|
or None,
|
||||||
chroma_server_host=chroma_server_host,
|
chroma_server_host=chroma_server_host,
|
||||||
chroma_server_port=chroma_server_port or None,
|
chroma_server_port=chroma_server_port or None,
|
||||||
chroma_server_grpc_port=chroma_server_grpc_port or None,
|
chroma_server_grpc_port=chroma_server_grpc_port or None,
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ class CustomComponent(Component):
|
||||||
"""The icon of the component. It should be an emoji. Defaults to None."""
|
"""The icon of the component. It should be an emoji. Defaults to None."""
|
||||||
is_input: Optional[bool] = None
|
is_input: Optional[bool] = None
|
||||||
"""The input state of the component. Defaults to None.
|
"""The input state of the component. Defaults to None.
|
||||||
If True, the component must have a field named 'message'."""
|
If True, the component must have a field named 'input_value'."""
|
||||||
is_output: Optional[bool] = None
|
is_output: Optional[bool] = None
|
||||||
"""The output state of the component. Defaults to None.
|
"""The output state of the component. Defaults to None.
|
||||||
If True, the component must have a field named 'message'."""
|
If True, the component must have a field named 'input_value'."""
|
||||||
code: Optional[str] = None
|
code: Optional[str] = None
|
||||||
"""The code of the component. Defaults to None."""
|
"""The code of the component. Defaults to None."""
|
||||||
field_config: dict = {}
|
field_config: dict = {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue