Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ccran
/
lufa-contract
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e047146d
authored
Jun 24, 2026
by
ccran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: llm add extra session support;
parent
c7bc7aac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
core/tools/segment_llm.py
+6
-3
utils/openai_util.py
+3
-1
No files found.
core/tools/segment_llm.py
View file @
e047146d
...
@@ -28,8 +28,8 @@ class LLMTool(ToolBase):
...
@@ -28,8 +28,8 @@ class LLMTool(ToolBase):
else
:
else
:
return
[{
"role"
:
"user"
,
"content"
:
user_content
}]
return
[{
"role"
:
"user"
,
"content"
:
user_content
}]
async
def
chat_async
(
self
,
messages
:
List
[
Dict
[
str
,
str
]]
)
:
async
def
chat_async
(
self
,
messages
:
List
[
Dict
[
str
,
str
]]
,
**
extra
)
->
str
:
return
await
self
.
llm
.
chat
(
messages
)
return
await
self
.
llm
.
chat
(
messages
,
**
extra
)
async
def
chat_batch_async
(
self
,
messages_list
:
List
[
List
[
Dict
[
str
,
str
]]]):
async
def
chat_batch_async
(
self
,
messages_list
:
List
[
List
[
Dict
[
str
,
str
]]]):
return
await
self
.
llm
.
mul_chat
(
messages_list
)
return
await
self
.
llm
.
mul_chat
(
messages_list
)
...
@@ -53,5 +53,7 @@ class LLMTool(ToolBase):
...
@@ -53,5 +53,7 @@ class LLMTool(ToolBase):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
tool
=
LLMTool
(
llm_key
=
"nanobot_llm"
)
tool
=
LLMTool
(
llm_key
=
"nanobot_llm"
)
results
=
asyncio
.
run
(
tool
.
chat_async
(
tool
.
build_messages
(
"列出工作目录"
)))
results
=
asyncio
.
run
(
tool
.
chat_async
(
tool
.
build_messages
(
"列出工作目录"
),
**
{
"session_id"
:
"test_session"
,
}))
print
(
results
)
print
(
results
)
\ No newline at end of file
utils/openai_util.py
View file @
e047146d
...
@@ -16,7 +16,7 @@ class OpenAITool:
...
@@ -16,7 +16,7 @@ class OpenAITool:
)
)
@retry
(
stop
=
stop_after_delay
(
600
)
|
stop_after_attempt
(
3
),
wait
=
wait_fixed
(
1
))
@retry
(
stop
=
stop_after_delay
(
600
)
|
stop_after_attempt
(
3
),
wait
=
wait_fixed
(
1
))
async
def
chat
(
self
,
msg
,
tools
=
None
):
async
def
chat
(
self
,
msg
,
tools
=
None
,
**
extra
):
if
tools
is
None
:
if
tools
is
None
:
extra_body
=
{}
extra_body
=
{}
# fastgpt专用:如果第一个消息是system角色,则将其内容放入extra_body.variables.system,并从消息列表中移除
# fastgpt专用:如果第一个消息是system角色,则将其内容放入extra_body.variables.system,并从消息列表中移除
...
@@ -27,6 +27,8 @@ class OpenAITool:
...
@@ -27,6 +27,8 @@ class OpenAITool:
# deepseek专用关闭思考
# deepseek专用关闭思考
extra_body
[
"thinking"
]
=
{
"type"
:
"disabled"
}
extra_body
[
"thinking"
]
=
{
"type"
:
"disabled"
}
extra_body
[
"chat_template_kwargs"
]
=
{
"enable_thinking"
:
False
}
extra_body
[
"chat_template_kwargs"
]
=
{
"enable_thinking"
:
False
}
if
extra
:
extra_body
.
update
(
extra
)
try
:
try
:
response
=
await
self
.
client
.
chat
.
completions
.
create
(
response
=
await
self
.
client
.
chat
.
completions
.
create
(
model
=
self
.
llm_config
.
model
,
messages
=
msg
,
extra_body
=
extra_body
model
=
self
.
llm_config
.
model
,
messages
=
msg
,
extra_body
=
extra_body
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment