优化:移除unused依赖、懒加载和容错处理
This commit is contained in:
4
ga.py
4
ga.py
@@ -1,4 +1,4 @@
|
|||||||
import sys, os, re, json, time, pyperclip, threading
|
import sys, os, re, json, time, threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import tempfile, traceback, subprocess, itertools, collections
|
import tempfile, traceback, subprocess, itertools, collections
|
||||||
if sys.stdout is None: sys.stdout = open(os.devnull, "w")
|
if sys.stdout is None: sys.stdout = open(os.devnull, "w")
|
||||||
@@ -22,7 +22,7 @@ def code_run(code: str, code_type: str = "python", timeout: int = 60, cwd: str =
|
|||||||
tmp_file.write(code)
|
tmp_file.write(code)
|
||||||
tmp_path = tmp_file.name
|
tmp_path = tmp_file.name
|
||||||
tmp_file.close()
|
tmp_file.close()
|
||||||
cmd = ["python", "-X", "utf8", "-u", tmp_path]
|
cmd = [sys.executable, "-X", "utf8", "-u", tmp_path]
|
||||||
elif code_type in ["powershell", "bash"]:
|
elif code_type in ["powershell", "bash"]:
|
||||||
if os.name == 'nt': cmd = ["powershell", "-NoProfile", "-NonInteractive", "-Command", code]
|
if os.name == 'nt': cmd = ["powershell", "-NoProfile", "-NonInteractive", "-Command", code]
|
||||||
else: cmd = ["bash", "-c", code]
|
else: cmd = ["bash", "-c", code]
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import os, json, re, time, requests
|
import os, json, re, time, requests
|
||||||
from sider_ai_api import Session
|
|
||||||
|
|
||||||
try: from mykey import sider_cookie
|
try: from mykey import sider_cookie
|
||||||
except ImportError: sider_cookie = ""
|
except ImportError: sider_cookie = ""
|
||||||
@@ -8,6 +7,7 @@ except ImportError: oai_apikey = oai_apibase = oai_model = ""
|
|||||||
|
|
||||||
class SiderLLMSession:
|
class SiderLLMSession:
|
||||||
def __init__(self, default_model="gemini-3.0-flash"):
|
def __init__(self, default_model="gemini-3.0-flash"):
|
||||||
|
from sider_ai_api import Session
|
||||||
self._core = Session(cookie=sider_cookie, proxies={'https':'127.0.0.1:2082'})
|
self._core = Session(cookie=sider_cookie, proxies={'https':'127.0.0.1:2082'})
|
||||||
self.default_model = default_model
|
self.default_model = default_model
|
||||||
def ask(self, prompt, model=None):
|
def ask(self, prompt, model=None):
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from bs4 import BeautifulSoup
|
try: from bs4 import BeautifulSoup
|
||||||
|
except ImportError: print("[Error] BeautifulSoup4 未安装,请叫Agent安装BeautifulSoup4,再使用web相关工具。")
|
||||||
|
|
||||||
js_optHTML = r'''function optHTML() {
|
js_optHTML = r'''function optHTML() {
|
||||||
function createEnhancedDOMCopy() {
|
function createEnhancedDOMCopy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user