mirror of https://github.com/chaitin/PandaWiki.git
Compare commits
5 Commits
06ab54e39b
...
31f684cf81
| Author | SHA1 | Date |
|---|---|---|
|
|
31f684cf81 | |
|
|
f77c94d5fb | |
|
|
da9039ff37 | |
|
|
797e0c033d | |
|
|
ea6f958d24 |
|
|
@ -23,9 +23,8 @@ type ChatRequest struct {
|
|||
Info ConversationInfo `json:"-"`
|
||||
}
|
||||
|
||||
type ChatRagOnlyRequset struct {
|
||||
Message string `json:"message" validate:"required"`
|
||||
CaptchaToken string `json:"captcha_token"`
|
||||
type ChatRagOnlyRequest struct {
|
||||
Message string `json:"message" validate:"required"`
|
||||
|
||||
KBID string `json:"-" validate:"required"`
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package domain
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type MCPCall struct {
|
||||
ID string `gorm:"primaryKey;column:id" json:"id,omitempty"`
|
||||
ClientName string `gorm:"column:client_name" json:"client_name"`
|
||||
ClientVersion string `gorm:"column:client_version" json:"client_version"`
|
||||
Question string `gorm:"column:question" json:"question"`
|
||||
Document string `gorm:"column:document" json:"document"`
|
||||
RemoteIP string `gorm:"column:remote_ip" json:"remoate_ip"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;not null;default:now()" json:"created_at"`
|
||||
}
|
||||
|
|
@ -137,29 +137,6 @@ func (r *KnowledgeBaseRepository) SyncKBAccessSettingsToCaddy(ctx context.Contex
|
|||
{
|
||||
"handler": "subroute",
|
||||
"routes": []map[string]any{
|
||||
{
|
||||
"match": []map[string]any{
|
||||
{
|
||||
"path": []string{"/mcp"},
|
||||
},
|
||||
},
|
||||
"handle": []map[string]any{
|
||||
{
|
||||
"handler": "headers",
|
||||
"request": map[string]any{
|
||||
"set": map[string][]any{
|
||||
"X-KB-ID": {kb.ID},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"handler": "reverse_proxy",
|
||||
"upstreams": []map[string]any{
|
||||
{"dial": api},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"match": []map[string]any{
|
||||
{
|
||||
|
|
@ -192,7 +169,7 @@ func (r *KnowledgeBaseRepository) SyncKBAccessSettingsToCaddy(ctx context.Contex
|
|||
{
|
||||
"match": []map[string]any{
|
||||
{
|
||||
"path": []string{"/share/v1/chat/completions", "/share/v1/app/wechat/app", "/share/v1/app/wechat/service", "/sitemap.xml", "/share/v1/app/wechat/official_account", "/share/v1/app/wechat/service/answer"},
|
||||
"path": []string{"/share/v1/chat/completions", "/share/v1/app/wechat/app", "/share/v1/app/wechat/service", "/sitemap.xml", "/share/v1/app/wechat/official_account", "/share/v1/app/wechat/service/answer", "/mcp"},
|
||||
},
|
||||
},
|
||||
"handle": []map[string]any{
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
DROP TABLE IF EXISTS mcp_calls;
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS mcp_calls (
|
||||
id SERIAL PRIMARY KEY,
|
||||
mcp_session_id TEXT NOT NULL,
|
||||
kb_id TEXT NOT NULL,
|
||||
remote_ip TEXT,
|
||||
initialize_req JSONB,
|
||||
initialize_resp JSONB,
|
||||
tool_call_req JSONB,
|
||||
tool_call_resp TEXT,
|
||||
created_at timestamptz NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
|
@ -301,7 +301,7 @@ func (u *ChatUsecase) Chat(ctx context.Context, req *domain.ChatRequest) (<-chan
|
|||
return eventCh, nil
|
||||
}
|
||||
|
||||
func (u *ChatUsecase) ChatRagOnly(ctx context.Context, req *domain.ChatRagOnlyRequset) (<-chan domain.SSEEvent, error) {
|
||||
func (u *ChatUsecase) ChatRagOnly(ctx context.Context, req *domain.ChatRagOnlyRequest) (<-chan domain.SSEEvent, error) {
|
||||
eventCh := make(chan domain.SSEEvent, 100)
|
||||
go func() {
|
||||
defer close(eventCh)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { VersionInfoMap } from '@/constant/version';
|
||||
import { useVersionInfo } from '@/hooks';
|
||||
import { ConstsLicenseEdition } from '@/request/types';
|
||||
import { styled, SxProps } from '@mui/material';
|
||||
import { styled, SxProps, Tooltip } from '@mui/material';
|
||||
import React from 'react';
|
||||
|
||||
const StyledMaskWrapper = styled('div')(({ theme }) => ({
|
||||
|
|
@ -95,24 +95,48 @@ export const VersionCanUse = ({
|
|||
ConstsLicenseEdition.LicenseEditionEnterprise,
|
||||
],
|
||||
sx,
|
||||
mode = 'text',
|
||||
}: {
|
||||
permission?: ConstsLicenseEdition[];
|
||||
sx?: SxProps;
|
||||
mode?: 'icon' | 'text';
|
||||
}) => {
|
||||
const versionInfo = useVersionInfo();
|
||||
const hasPermission = permission.includes(versionInfo.permission);
|
||||
if (hasPermission) return null;
|
||||
const nextVersionInfo = VersionInfoMap[permission[0]];
|
||||
return (
|
||||
<StyledMaskContent sx={{ width: 'auto', ml: 1, ...sx }}>
|
||||
<StyledMaskVersion sx={{ backgroundColor: nextVersionInfo.bgColor }}>
|
||||
<img
|
||||
src={nextVersionInfo.image}
|
||||
style={{ width: 12, objectFit: 'contain', marginTop: 1 }}
|
||||
alt={nextVersionInfo.label}
|
||||
/>
|
||||
{nextVersionInfo?.label}可用
|
||||
</StyledMaskVersion>
|
||||
<StyledMaskContent
|
||||
sx={{
|
||||
width: 'auto',
|
||||
ml: mode === 'icon' ? 0.5 : 1,
|
||||
// 允许 Tooltip 在 disabled 的父元素中正常工作
|
||||
pointerEvents: 'auto',
|
||||
...sx,
|
||||
}}
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}}
|
||||
>
|
||||
{mode === 'icon' ? (
|
||||
<Tooltip title={nextVersionInfo.label + '可用'} placement='top' arrow>
|
||||
<img
|
||||
src={nextVersionInfo.image}
|
||||
style={{ width: 14, objectFit: 'contain' }}
|
||||
alt={nextVersionInfo.label}
|
||||
/>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<StyledMaskVersion sx={{ backgroundColor: nextVersionInfo.bgColor }}>
|
||||
<img
|
||||
src={nextVersionInfo.image}
|
||||
style={{ width: 12, objectFit: 'contain', marginTop: 1 }}
|
||||
alt={nextVersionInfo.label}
|
||||
/>
|
||||
{nextVersionInfo?.label}可用
|
||||
</StyledMaskVersion>
|
||||
)}
|
||||
</StyledMaskContent>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,9 +36,17 @@ const Statistic = () => {
|
|||
{ label: '近 24 小时', value: 1, disabled: false },
|
||||
{
|
||||
label: (
|
||||
<Stack direction={'row'} alignItems={'center'} gap={0.5}>
|
||||
<Stack
|
||||
direction={'row'}
|
||||
alignItems={'center'}
|
||||
gap={0.5}
|
||||
sx={{ lineHeight: 1 }}
|
||||
>
|
||||
<span>近 7 天</span>
|
||||
<VersionCanUse permission={PROFESSION_VERSION_PERMISSION} />
|
||||
<VersionCanUse
|
||||
permission={PROFESSION_VERSION_PERMISSION}
|
||||
mode='icon'
|
||||
/>
|
||||
</Stack>
|
||||
),
|
||||
value: 7,
|
||||
|
|
@ -46,9 +54,17 @@ const Statistic = () => {
|
|||
},
|
||||
{
|
||||
label: (
|
||||
<Stack direction={'row'} alignItems={'center'} gap={0.5}>
|
||||
<Stack
|
||||
direction={'row'}
|
||||
alignItems={'center'}
|
||||
gap={0.5}
|
||||
sx={{ lineHeight: 1 }}
|
||||
>
|
||||
<span>近 30 天</span>
|
||||
<VersionCanUse permission={BUSINESS_VERSION_PERMISSION} />
|
||||
<VersionCanUse
|
||||
permission={BUSINESS_VERSION_PERMISSION}
|
||||
mode='icon'
|
||||
/>
|
||||
</Stack>
|
||||
),
|
||||
value: 30,
|
||||
|
|
@ -56,9 +72,17 @@ const Statistic = () => {
|
|||
},
|
||||
{
|
||||
label: (
|
||||
<Stack direction={'row'} alignItems={'center'} gap={0.5}>
|
||||
<Stack
|
||||
direction={'row'}
|
||||
alignItems={'center'}
|
||||
gap={0.5}
|
||||
sx={{ lineHeight: 1 }}
|
||||
>
|
||||
<span>近 90 天</span>
|
||||
<VersionCanUse permission={BUSINESS_VERSION_PERMISSION} />
|
||||
<VersionCanUse
|
||||
permission={BUSINESS_VERSION_PERMISSION}
|
||||
mode='icon'
|
||||
/>
|
||||
</Stack>
|
||||
),
|
||||
value: 90,
|
||||
|
|
|
|||
Loading…
Reference in New Issue