Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bme-mcp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何家明
bme-mcp
Commits
a8552474
Commit
a8552474
authored
Oct 23, 2025
by
何家明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加post接口
parent
40105bef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
api.py
api.py
+11
-0
AiChatParam.py
model/param/AiChatParam.py
+5
-0
No files found.
api.py
View file @
a8552474
...
...
@@ -12,6 +12,7 @@ from config.system import config
from
model.entity.AiChatPermissionEntity
import
AiChatPermissionEntity
from
model.entity.AiChatRecommendQuestionEntity
import
AiChatRecommendQuestionEntity
from
model.entity.AiChatRecordEntity
import
AiChatRecordEntity
from
model.param.AiChatParam
import
AiChatParam
from
model.vo.ResultVo
import
ResultVo
...
...
@@ -99,6 +100,16 @@ async def chat(request: Request, message: str):
return
EventSourceResponse
(
mcp_client_instance
.
process_query
(
message
,
id_str
.
split
(
"-"
)[
0
]),
media_type
=
"text/event-stream"
,
headers
=
{
"Cache-Control"
:
"no-cache"
})
@
router
.
post
(
path
=
"/chat"
,
description
=
"AI对话"
)
async
def
chat
(
request
:
Request
,
param
:
AiChatParam
):
id_str
=
request
.
headers
.
get
(
"id"
,
""
)
if
not
id_str
:
def
error_generator
():
yield
ServerSentEvent
(
event
=
"error"
)
return
EventSourceResponse
(
error_generator
())
return
EventSourceResponse
(
mcp_client_instance
.
process_query
(
param
.
message
,
id_str
.
split
(
"-"
)[
0
]),
media_type
=
"text/event-stream"
,
headers
=
{
"Cache-Control"
:
"no-cache"
})
if
__name__
==
"__main__"
:
cors
=
config
.
get
(
"cors"
,
{})
...
...
model/param/AiChat
Record
Param.py
→
model/param/AiChatParam.py
View file @
a8552474
from
pydantic
import
BaseModel
class
AiChatRecordParam
(
BaseModel
):
id
:
int
answer
:
str
class
AiChatParam
(
BaseModel
):
message
:
str
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