Zum Inhalt

LangChain Code-Knoten#

Verwenden Sie den LangChain Code-Knoten, um LangChain zu importieren. Das bedeutet, wenn Sie eine Funktionalität benötigen, für die Localmind Automate keinen Knoten erstellt hat, können Sie diese trotzdem nutzen. Durch die Konfiguration der Konnektoren des LangChain Code-Knotens können Sie ihn als normalen Knoten, Root-Knoten oder Sub-Knoten verwenden.

Auf dieser Seite finden Sie die Knotenparameter, Anleitungen zur Konfiguration des Knotens und Links zu weiteren Ressourcen.

Knotenparameter#

Code hinzufügen#

Fügen Sie Ihren benutzerdefinierten Code hinzu. Wählen Sie entweder den Modus Ausführen oder Daten bereitstellen. Sie können nur einen Modus verwenden.

Im Gegensatz zum Code-Knoten unterstützt der LangChain Code-Knoten kein Python.

  • Ausführen: Verwenden Sie den LangChain Code-Knoten wie den eigenen Code-Knoten von LOCALMIND_AUTOMATE. Dieser nimmt Eingabedaten aus dem Workflow entgegen, verarbeitet sie und gibt sie als Knotenausgabe zurück. Dieser Modus erfordert eine Haupteingabe und -ausgabe. Sie müssen diese Verbindungen in Eingänge und Ausgänge erstellen.
  • Daten bereitstellen: Verwenden Sie den LangChain Code-Knoten als Sub-Knoten und senden Sie Daten an einen Root-Knoten. Dies verwendet eine andere Ausgabe als die Hauptausgabe.

Eingänge#

Wählen Sie die Eingabetypen aus.

Die Haupteingabe ist der normale Konnektor, der in allen Localmind Automate-Workflows zu finden ist. Wenn Sie eine Haupt-Ein- und -Ausgabe im Knoten festgelegt haben, ist Ausführen-Code erforderlich.

Ausgänge#

Wählen Sie die Ausgabetypen aus.

Die Hauptausgabe ist der normale Konnektor, der in allen Localmind Automate-Workflows zu finden ist. Wenn Sie eine Haupt-Ein- und -Ausgabe im Knoten festgelegt haben, ist Ausführen-Code erforderlich.

Konfiguration der Knoten-Ein- und -Ausgänge#

Durch die Konfiguration der Konnektoren (Ein- und Ausgänge) des LangChain Code-Knotens können Sie ihn als App-Knoten, Root-Knoten oder Sub-Knoten verwenden.

Knotentyp Eingänge Ausgänge Code-Modus
App-Knoten. Ähnlich dem Code-Knoten. Haupt Haupt Ausführen
Root-Knoten Haupt; mindestens ein anderer Typ Haupt Ausführen
Sub-Knoten - Ein anderer Typ als Haupt. Muss mit dem Eingabetyp übereinstimmen, mit dem Sie sich verbinden möchten. Daten bereitstellen
Sub-Knoten mit Sub-Knoten Ein anderer Typ als Haupt Ein anderer Typ als Haupt. Muss mit dem Eingabetyp übereinstimmen, mit dem Sie sich verbinden möchten. Daten bereitstellen

Integrierte Methoden#

Localmind Automate bietet diese Methoden, um es einfacher zu machen, gängige Aufgaben im LangChain Code-Knoten auszuführen.

Method Description
this.addInputData(inputName, data) Populate the data of a specified non-main input. Useful for mocking data.
  • inputName is the input connection type, and must be one of: ai_agent, ai_chain, ai_document, ai_embedding, ai_languageModel, ai_memory, ai_outputParser, ai_retriever, ai_textSplitter, ai_tool, ai_vectorRetriever, ai_vectorStore
  • data contains the data you want to add. Refer to Data structure for information on the data structure expected by Localmind Automate.
this.addOutputData(outputName, data) Populate the data of a specified non-main output. Useful for mocking data.
  • outputName is the input connection type, and must be one of: ai_agent, ai_chain, ai_document, ai_embedding, ai_languageModel, ai_memory, ai_outputParser, ai_retriever, ai_textSplitter, ai_tool, ai_vectorRetriever, ai_vectorStore
  • data contains the data you want to add. Refer to Data structure for information on the data structure expected by Localmind Automate.
this.getInputConnectionData(inputName, itemIndex, inputIndex?) Get data from a specified non-main input.
  • inputName is the input connection type, and must be one of: ai_agent, ai_chain, ai_document, ai_embedding, ai_languageModel, ai_memory, ai_outputParser, ai_retriever, ai_textSplitter, ai_tool, ai_vectorRetriever, ai_vectorStore
  • itemIndex should always be 0 (this parameter will be used in upcoming functionality)
  • Use inputIndex if there is more than one node connected to the specified input.
this.getInputData(inputIndex?, inputName?) Get data from the main input.
this.getNode() Get the current node.
this.getNodeOutputs() Get the outputs of the current node.
this.getExecutionCancelSignal() Use this to stop the execution of a function when the workflow stops. In most cases Localmind Automate handles this, but you may need to use it if building your own chains or agents. It replaces the Cancelling a running LLMChain code that you'd use if building a LangChain application normally.

Verwandte Ressourcen#

View Localmind Automate's Advanced AI documentation.

AI glossary#

  • completion: Completions are the responses generated by a model like GPT.
  • hallucinations: Hallucination in AI is when an LLM (large language model) mistakenly perceives patterns or objects that don't exist.
  • vector database: A vector database stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.
  • vector store: A vector store, or vector database, stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.