mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Refa: improve usability of Node.js/JavaScript code executor (#8979)
### What problem does this PR solve? Improve usability of Node.js/JavaScript code executor. ### Type of change - [x] Refactoring --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com> Co-authored-by: writinwaters <93570324+writinwaters@users.noreply.github.com>
This commit is contained in:
@ -213,6 +213,42 @@ To add Node.js dependencies:
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### 🐍 A Python example
|
||||
|
||||
```python
|
||||
def main(arg1: str, arg2: str) -> str:
|
||||
return f"result: {arg1 + arg2}"
|
||||
```
|
||||
|
||||
### 🟨 JavaScript examples
|
||||
|
||||
A simple sync function
|
||||
|
||||
```javascript
|
||||
function main({arg1, arg2}) {
|
||||
return arg1+arg2
|
||||
}
|
||||
```
|
||||
|
||||
Async funcion with aioxs
|
||||
|
||||
```javascript
|
||||
const axios = require('axios');
|
||||
async function main() {
|
||||
try {
|
||||
const response = await axios.get('https://github.com/infiniflow/ragflow');
|
||||
return 'Body:' + response.data;
|
||||
} catch (error) {
|
||||
return 'Error:' + error.message;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 FAQ
|
||||
|
||||
### ❓Sandbox Not Working?
|
||||
|
||||
Reference in New Issue
Block a user