Zum Inhalt

Custom Code Tool Node#

Verwenden Sie den Custom Code Tool Node, um Code zu schreiben, den ein Agent ausführen kann.

Auf dieser Seite finden Sie die Node-Parameter für den Custom Code Tool Node und Links zu weiteren Ressourcen.

Parameter resolution in sub-nodes

Sub-nodes behave differently to other nodes when processing multiple items using an expression.

Most nodes, including root nodes, take any number of items as input, process these items, and output the results. You can use expressions to refer to input items, and the node resolves the expression for each item in turn. For example, given an input of five name values, the expression {{ $json.name }} resolves to each name in turn.

In sub-nodes, the expression always resolves to the first item. For example, given an input of five name values, the expression {{ $json.name }} always resolves to the first name.

Node-Parameter#

Name#

Geben Sie Ihrem benutzerdefinierten Code einen Namen. Er darf keine Leerzeichen enthalten.

Beschreibung#

Geben Sie Ihrem benutzerdefinierten Code eine Beschreibung. Dies teilt dem Agenten mit, wann er dieses Tool verwenden soll. Zum Beispiel:

Rufen Sie dieses Tool auf, um eine zufällige Farbe zu erhalten. Die Eingabe sollte eine Zeichenkette mit durch Kommas getrennten Namen von auszuschließenden Farben sein.

Sprache#

Sie können JavaScript oder Python verwenden.

JavaScript / Python-Feld#

Schreiben Sie hier den Code.

Sie können auf die Tool-Eingabe mit query zugreifen. Um beispielsweise die Eingabezeichenkette zu nehmen und in Kleinbuchstaben umzuwandeln:

1
2
let myString = query;
return myString.toLowerCase();

Verwandte Ressourcen#

Refer to LangChain's documentation on tools for more information about tools in LangChain.

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.