docs: Audit use of tabs and details (#9196)

* audit details

* tabs pt 1

* tabs pt 2

* tabs pt 3

* tabs to details
This commit is contained in:
April I. Murphy 2025-07-28 10:09:14 -07:00 • committed by GitHub
commit 7f04e15602
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 1067 additions and 1195 deletions

View file

@ -46,92 +46,92 @@ For example, the default tool name is `Agent`. Edit the name to `Agent-gpt-41`,
## Add custom components as tools {#components-as-tools}
An agent can use custom components as tools.
An agent can use [custom components](/components-custom-components) as tools.
1. To add a custom component to the agent flow, click **New Custom Component**.
2. Add custom Python code to the custom component.
For example, to create a text analyzer component, paste the below code into the custom component's **Code** pane.
2. Enter Python code into the **Code** pane to create the custom component.
<details open>
<summary>Python</summary>
If you don't already have code for a custom component, you can use the following code snippet as an example before creating your own.
```python
from langflow.custom import Component
from langflow.io import MessageTextInput, Output
from langflow.schema import Data
import re
<details>
<summary>Text Analyzer custom component</summary>
class TextAnalyzerComponent(Component):
display_name = "Text Analyzer"
description = "Analyzes and transforms input text."
documentation: str = "http://docs.langflow.org/components/custom"
icon = "chart-bar"
name = "TextAnalyzerComponent"
This code creates a text analyzer component.
inputs = [
MessageTextInput(
name="input_text",
display_name="Input Text",
info="Enter text to analyze",
value="Hello, World!",
tool_mode=True,
),
]
```python
from langflow.custom import Component
from langflow.io import MessageTextInput, Output
from langflow.schema import Data
import re
outputs = [
Output(display_name="Analysis Result", name="output", method="analyze_text"),
]
class TextAnalyzerComponent(Component):
display_name = "Text Analyzer"
description = "Analyzes and transforms input text."
documentation: str = "http://docs.langflow.org/components/custom"
icon = "chart-bar"
name = "TextAnalyzerComponent"
def analyze_text(self) -> Data:
text = self.input_text
inputs = [
MessageTextInput(
name="input_text",
display_name="Input Text",
info="Enter text to analyze",
value="Hello, World!",
tool_mode=True,
),
]
# Perform text analysis
word_count = len(text.split())
char_count = len(text)
sentence_count = len(re.findall(r'\w+[.!?]', text))
outputs = [
Output(display_name="Analysis Result", name="output", method="analyze_text"),
]
# Transform text
reversed_text = text[::-1]
uppercase_text = text.upper()
def analyze_text(self) -> Data:
text = self.input_text
analysis_result = {
"original_text": text,
"word_count": word_count,
"character_count": char_count,
"sentence_count": sentence_count,
"reversed_text": reversed_text,
"uppercase_text": uppercase_text
}
# Perform text analysis
word_count = len(text.split())
char_count = len(text)
sentence_count = len(re.findall(r'\w+[.!?]', text))
data = Data(value=analysis_result)
self.status = data
return data
```
</details>
# Transform text
reversed_text = text[::-1]
uppercase_text = text.upper()
analysis_result = {
"original_text": text,
"word_count": word_count,
"character_count": char_count,
"sentence_count": sentence_count,
"reversed_text": reversed_text,
"uppercase_text": uppercase_text
}
data = Data(value=analysis_result)
self.status = data
return data
```
</details>
3. To use the custom component as a tool, click **Tool Mode**.
4. Connect the custom component's tool output to the agent's tools input.
5. Open the <Icon name="Play" aria-hidden="true" /> **Playground** and instruct the agent, `Use the text analyzer on this text: "Agents really are thinking machines!"`
<details open>
<summary>Response</summary>
```
AI
gpt-4o
Finished
0.6s
Here is the analysis of the text "Agents really are thinking machines!":
Original Text: Agents really are thinking machines!
Word Count: 5
Character Count: 36
Sentence Count: 1
Reversed Text: !senihcam gnikniht era yllaer stnegA
Uppercase Text: AGENTS REALLY ARE THINKING MACHINES!
```
</details>
Based on your instruction, the agent should call the `analyze_text` action and return the result.
For example:
The agent correctly calls the `analyze_text` action and returns the result to the Playground.
```
gpt-4o
Finished
0.6s
Here is the analysis of the text "Agents really are thinking machines!":
Original Text: Agents really are thinking machines!
Word Count: 5
Character Count: 36
Sentence Count: 1
Reversed Text: !senihcam gnikniht era yllaer stnegA
Uppercase Text: AGENTS REALLY ARE THINKING MACHINES!
```
## Make any component a tool