From 59934b63aabf50db47c916f2686bb2ac60167eac Mon Sep 17 00:00:00 2001 From: writinwaters <93570324+writinwaters@users.noreply.github.com> Date: Fri, 23 May 2025 18:30:02 +0800 Subject: [PATCH] Docs: Added code component reference (#7821) ### What problem does this PR solve? ### Type of change - [x] Documentation Update --- .../agent/agent_component_reference/code.mdx | 50 +++++++++++++++++++ .../agent/agent_component_reference/note.mdx | 2 +- docs/release_notes.md | 8 +-- 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 docs/guides/agent/agent_component_reference/code.mdx diff --git a/docs/guides/agent/agent_component_reference/code.mdx b/docs/guides/agent/agent_component_reference/code.mdx new file mode 100644 index 000000000..cb572f6d1 --- /dev/null +++ b/docs/guides/agent/agent_component_reference/code.mdx @@ -0,0 +1,50 @@ +--- +sidebar_position: 13 +slug: /code_component +--- + +# Code component + +A component that enables users to integrate Python or JavaScript codes into their Agent for dynamic data processing. + +--- + +## Scenarios + +A **Code** component is essential when you need to integrate complex code logic (Python or JavaScript) into your Agent for dynamic data processing. + +## Input variables + +You can specify multiple input sources for the **Code** component. Click **+ Add variable** in the **Input variables** section to include the desired input variables. + +After defining an input variable, you are required to select from the dropdown menu: + - A component ID under **Component Output**, or + - A global variable under **Begin input**, which is defined in the **Begin** component. + +## Coding field + +### A Python code example + +```Python + def main(arg1: str, arg2: str) -> dict: + return { + "result": arg1 + arg2, + } +``` + +### A JavaScript code example + +```JavaScript + + const axios = require('axios'); + async function main(args) { + try { + const response = await axios.get('https://github.com/infiniflow/ragflow'); + console.log('Body:', response.data); + } catch (error) { + console.error('Error:', error.message); + } + } +``` + + diff --git a/docs/guides/agent/agent_component_reference/note.mdx b/docs/guides/agent/agent_component_reference/note.mdx index 445648a36..015e40b2b 100644 --- a/docs/guides/agent/agent_component_reference/note.mdx +++ b/docs/guides/agent/agent_component_reference/note.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 13 +sidebar_position: 18 slug: /note_component --- diff --git a/docs/release_notes.md b/docs/release_notes.md index aa61e7eb3..fa6cd507c 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -31,13 +31,13 @@ Released on May 26, 2025. - Cross-language search is supported in the Knowledge and Chat modules, enhancing search accuracy and user experience in multilingual environments, such as in Chinese-English knowledge bases. - Agent component: A new Code component supports Python and JavaScript scripts, enabling developers to handle more complex tasks like dynamic data processing. - Enhanced image display: Images in Chat and Search now render directly within responses, rather than as external references. Knowledge retrieval testing can retrieve images directly, instead of texts extracted from images. -- Claude 4: Developers can now use the newly released, most advanced Claude model. +- Claude 4 and ChatGPT o3: Developers can now use the newly released, most advanced Claude model alongside OpenAI’s latest ChatGPT o3 inference model. > The following features are contributed by our community contributors: -- Agent component: Enables tool calling within the Generate Component. Kudos to [notsyncing](https://github.com/notsyncing). -- Markdown rendering: Image references in a markdown file can be displayed after chunking. Kudos to [Woody-Hu](https://github.com/Woody-Hu). -- Vector database support: OpenSearch can now be used as RAGFlow's document engine. Kudos to [pyyuhao](https://github.com/pyyuhao). +- Agent component: Enables tool calling within the Generate Component. Thanks to [notsyncing](https://github.com/notsyncing). +- Markdown rendering: Image references in a markdown file can be displayed after chunking. Thanks to [Woody-Hu](https://github.com/Woody-Hu). +- Document engine support: OpenSearch can now be used as RAGFlow's document engine. Thanks to [pyyuhao](https://github.com/pyyuhao). ## v0.18.0