maintenance: update project dependencies and improve file handling
feat: add autonomous mode with command-line argument refactor: improve assistant output and result tracking refactor: handle autonomous mode in assistant refactor: improve error handling in web tools
This commit is contained in:
parent
cc4b0e46e1
commit
a3d5696c19
@ -19,6 +19,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Version 1.23.0 - 2025-11-07
|
||||
|
||||
This release updates project dependencies and improves file handling. The changelog now includes details about the previous version (1.22.0).
|
||||
|
||||
**Changes:** 4 files, 23 lines
|
||||
**Languages:** Markdown (8 lines), Other (3 lines), TOML (2 lines), Text (10 lines)
|
||||
|
||||
## Version 1.22.0 - 2025-11-07
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "rp"
|
||||
version = "1.22.0"
|
||||
version = "1.23.0"
|
||||
description = "R python edition. The ultimate autonomous AI CLI."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
@ -44,6 +44,7 @@ Commands in interactive mode:
|
||||
parser.add_argument("-u", "--api-url", help="API endpoint URL")
|
||||
parser.add_argument("--model-list-url", help="Model list endpoint URL")
|
||||
parser.add_argument("-i", "--interactive", action="store_true", help="Interactive mode")
|
||||
parser.add_argument("-a", "--autonomous", action="store_true", help="Autonomous mode")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose output")
|
||||
parser.add_argument(
|
||||
"--debug", action="store_true", help="Enable debug mode with detailed logging"
|
||||
|
||||
@ -105,6 +105,7 @@ class Assistant:
|
||||
self.background_monitoring = False
|
||||
self.usage_tracker = UsageTracker()
|
||||
self.background_tasks = set()
|
||||
self.last_result = None
|
||||
self.init_database()
|
||||
self.messages.append(init_system_message(args))
|
||||
try:
|
||||
@ -405,7 +406,9 @@ class Assistant:
|
||||
# Use enhanced processing if available, otherwise fall back to basic processing
|
||||
if hasattr(self, "enhanced") and self.enhanced:
|
||||
result = self.enhanced.process_with_enhanced_context(user_input)
|
||||
print(result)
|
||||
if result != self.last_result:
|
||||
print(result)
|
||||
self.last_result = result
|
||||
else:
|
||||
process_message(self, user_input)
|
||||
except EOFError:
|
||||
@ -423,6 +426,19 @@ class Assistant:
|
||||
message = sys.stdin.read()
|
||||
process_message(self, message)
|
||||
|
||||
def run_autonomous(self):
|
||||
|
||||
if self.args.message:
|
||||
task = self.args.message
|
||||
else:
|
||||
self.setup_readline()
|
||||
task = input("> ").strip()
|
||||
if not task:
|
||||
print("No task provided. Exiting.")
|
||||
return
|
||||
from rp.autonomous import run_autonomous_mode
|
||||
run_autonomous_mode(self, task)
|
||||
|
||||
def cleanup(self):
|
||||
if hasattr(self, "enhanced") and self.enhanced:
|
||||
try:
|
||||
@ -446,7 +462,9 @@ class Assistant:
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if self.args.interactive or (not self.args.message and sys.stdin.isatty()):
|
||||
if self.args.autonomous or (not self.args.interactive and not self.args.message and sys.stdin.isatty()):
|
||||
self.run_autonomous()
|
||||
elif self.args.interactive:
|
||||
self.run_repl()
|
||||
else:
|
||||
self.run_single()
|
||||
@ -482,4 +500,6 @@ def process_message(assistant, message):
|
||||
total_cost = assistant.usage_tracker.session_usage["estimated_cost"]
|
||||
print(f"{Colors.YELLOW}💰 Cost: ${cost:.4f} | Total: ${total_cost:.4f}{Colors.RESET}")
|
||||
result = assistant.process_response(response)
|
||||
print(f"\n{Colors.GREEN}r:{Colors.RESET} {result}\n")
|
||||
if result != assistant.last_result:
|
||||
print(f"\n{Colors.GREEN}r:{Colors.RESET} {result}\n")
|
||||
assistant.last_result = result
|
||||
|
||||
@ -4,6 +4,11 @@ import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
|
||||
import json
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
|
||||
def http_fetch(url, headers=None):
|
||||
"""Fetch content from an HTTP URL.
|
||||
|
||||
@ -15,25 +20,26 @@ def http_fetch(url, headers=None):
|
||||
Dict with status and content.
|
||||
"""
|
||||
try:
|
||||
req = urllib.request.Request(url)
|
||||
request = urllib.request.Request(url)
|
||||
if headers:
|
||||
for key, value in headers.items():
|
||||
req.add_header(key, value)
|
||||
with urllib.request.urlopen(req) as response:
|
||||
for header_key, header_value in headers.items():
|
||||
request.add_header(header_key, header_value)
|
||||
with urllib.request.urlopen(request) as response:
|
||||
content = response.read().decode("utf-8")
|
||||
return {"status": "success", "content": content[:10000]}
|
||||
except Exception as e:
|
||||
return {"status": "error", "error": str(e)}
|
||||
except Exception as exception:
|
||||
return {"status": "error", "error": str(exception)}
|
||||
|
||||
|
||||
def _perform_search(base_url, query, params=None):
|
||||
try:
|
||||
full_url = f"https://static.molodetz.nl/search.cgi?query={query}"
|
||||
encoded_query = urllib.parse.quote(query)
|
||||
full_url = f"{base_url}?query={encoded_query}"
|
||||
with urllib.request.urlopen(full_url) as response:
|
||||
content = response.read().decode("utf-8")
|
||||
return {"status": "success", "content": json.loads(content)}
|
||||
except Exception as e:
|
||||
return {"status": "error", "error": str(e)}
|
||||
except Exception as exception:
|
||||
return {"status": "error", "error": str(exception)}
|
||||
|
||||
|
||||
def web_search(query):
|
||||
@ -60,3 +66,4 @@ def web_search_news(query):
|
||||
"""
|
||||
base_url = "https://search.molodetz.nl/search"
|
||||
return _perform_search(base_url, query)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user