langflow
langflow copied to clipboard
refactor(tools): overhaul Python REPL component with modern tool mode
BREAKING CHANGE: Complete redesign of PythonREPL component architecture
- Replace legacy tool mode with modern tool_mode=true implementation
- Add automatic import detection for both global and from-imports
- Remove manual global_imports field in favor of automatic detection
- Implement CodeInput type support with FieldTypes.CODE
- Update schema to handle new parameters for agent compatibility
- Improve error handling and logging for import failures
The component now automatically handles imports without manual configuration, supports modern tool mode, and provides better integration with the agent system through updated schema definitions.
code used on the example:
import random
from datetime import datetime, timedelta
from typing import List, Dict
def generate_dates(quantity: int) -> List[Dict[str, str]]:
dates = []
base_date = datetime.now()
for i in range(quantity):
# Add random days to base date
days = random.randint(1, 365)
new_date = base_date + timedelta(days=days)
dates.append({
"date": new_date.strftime("%d/%m/%Y"),
"weekday": new_date.strftime("%A")
})
return dates
# Usage example
generated_dates = generate_dates(3)
for date in generated_dates:
print(f"Date: {date['date']}, Day: {date['weekday']}")
Or just run the code without the Agent:
CodeInput terminal:
the output:
@ogabrielluiz @edwinjosechittilappilly
CodSpeed Performance Report
Merging #5463 will degrade performances by 93.77%
Comparing Vigtu:python-REPL-Overhaul (3aa2885) with main (6ac45a8)
Summary
❌ 1 regressions
✅ 14 untouched benchmarks
:warning: Please fix the performance issues or acknowledge them on CodSpeed.
Benchmarks breakdown
| Benchmark | main |
Vigtu:python-REPL-Overhaul |
Change | |
|---|---|---|---|---|
| ❌ | test_successful_run_with_input_type_text |
259.5 ms | 4,165.9 ms | -93.77% |