Auto-commit: sync local changes
This commit is contained in:
12
agentapp.py
12
agentapp.py
@@ -18,10 +18,14 @@ from agent_loop import agent_runner_loop, StepOutcome, BaseHandler
|
|||||||
@st.cache_resource
|
@st.cache_resource
|
||||||
def init():
|
def init():
|
||||||
if not os.path.exists('temp'): os.makedirs('temp')
|
if not os.path.exists('temp'): os.makedirs('temp')
|
||||||
llm_sessions = [SiderLLMSession(default_model="gemini-3.0-flash"),
|
from sidercall import sider_cookie, oai_apikey, oai_apibase
|
||||||
SiderLLMSession(default_model="gpt-5-mini"),
|
llm_sessions = []
|
||||||
SiderLLMSession(default_model="claude-4.5-haiku"),
|
if sider_cookie: llm_sessions += [SiderLLMSession(default_model=x) for x in \
|
||||||
LLMSession()]
|
["gemini-3.0-flash", "claude-4.5-haiku", "gpt-5-mini"]]
|
||||||
|
if oai_apikey: llm_sessions += [LLMSession(api_key=oai_apikey, api_base=oai_apibase)]
|
||||||
|
if len(llm_sessions) == 0:
|
||||||
|
st.error("⚠️ 未配置任何可用的 LLM 接口,请在 mykey.py 中添加 sider_cookie 或 oai_apikey+oai_apibase 等信息后重启。")
|
||||||
|
st.stop()
|
||||||
llmclient = ToolClient([x.ask for x in llm_sessions], auto_save_tokens=True)
|
llmclient = ToolClient([x.ask for x in llm_sessions], auto_save_tokens=True)
|
||||||
return llmclient
|
return llmclient
|
||||||
|
|
||||||
|
|||||||
7
mykey_template.py
Normal file
7
mykey_template.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
oai_apikey = 'sk-uklUR...'
|
||||||
|
oai_apibase = "http://113.345.339.347:3001/v1"
|
||||||
|
|
||||||
|
# or
|
||||||
|
|
||||||
|
sider_cookie = 'token=Bearer%20eyJhbGciOiJIUz...'
|
||||||
13
sidercall.py
13
sidercall.py
@@ -1,14 +1,13 @@
|
|||||||
import os, json, re, time, requests
|
import os, json, re, time, requests
|
||||||
from sider_ai_api import Session
|
from sider_ai_api import Session
|
||||||
|
|
||||||
try:
|
try: from mykey import sider_cookie
|
||||||
from mykey import sider_cookie, capikey
|
except ImportError: sider_cookie = ""
|
||||||
except ImportError:
|
try: from mykey import oai_apikey, oai_apibase
|
||||||
sider_cookie = ""
|
except ImportError: oai_apikey = oai_apibase = ""
|
||||||
capikey = ""
|
|
||||||
|
|
||||||
class SiderLLMSession:
|
class SiderLLMSession:
|
||||||
def __init__(self, multiturns=6, default_model="gemini-3.0-flash"):
|
def __init__(self, default_model="gemini-3.0-flash"):
|
||||||
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):
|
||||||
@@ -19,7 +18,7 @@ class SiderLLMSession:
|
|||||||
return ''.join(self._core.chat(prompt, model))
|
return ''.join(self._core.chat(prompt, model))
|
||||||
|
|
||||||
class LLMSession:
|
class LLMSession:
|
||||||
def __init__(self, api_key=capikey, api_base="http://113.45.39.247:3001/v1", multiturns=6, context_win=32000):
|
def __init__(self, api_key=oai_apikey, api_base=oai_apibase, context_win=32000):
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
self.api_base = api_base
|
self.api_base = api_base
|
||||||
self.raw_msgs = []
|
self.raw_msgs = []
|
||||||
|
|||||||
Reference in New Issue
Block a user