langgenius / langgenius/dify-sandbox

How to obtain output only through the function's return value, rather than having to use print?

Open
#165 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.3k
Forks
326
Avg merge
56m
Merged PRs (30d)
3

Description

- Here is a sample code. In the code
```PYTHON
# declare main function here
def main() -> dict:
print(1111)
return {"message": [1, 2, 3]}


output = main()
result = f"""<>
{output}
<>"""

print(result)
```

- The API call returns data as follows
```JSON
{
"code": 0,
"message": "success",
"data": {
"error": "",
"stdout": "1111\n<>\n{'message': [1, 2, 3]}\n<>\n"
}
}
```

- In the code, I only want to get the returned result, but the interface will also output other debugging print information. Can this be achieved?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Python main() example and the API response's stdout field. Trace how returned data and print output are combined, then verify that the API can expose only the function's returned result while excluding debugging output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, python
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.