WEB API independent

This commit is contained in:
tuyang.yhj 2023-06-29 20:41:05 +08:00
parent 35bdf71912
commit 865822d1de
8 changed files with 16 additions and 9 deletions

View File

@ -2,7 +2,10 @@
const nextConfig = {
experimental: {
esmExternals: 'loose'
}
},
images: {
unoptimized: true
},
}
module.exports = nextConfig

View File

@ -6,7 +6,9 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"export": "next export",
"compile": "next build && next export"
},
"dependencies": {
"@ant-design/pro-components": "^2.6.2",

View File

@ -2,7 +2,7 @@ import { message } from 'antd';
import axios from 'axios';
import { isPlainObject } from 'lodash';
axios.defaults.baseURL = 'http://30.183.154.8:5000';
axios.defaults.baseURL = 'http://localhost:5000';
axios.defaults.timeout = 10000;

Binary file not shown.

View File

@ -2,13 +2,13 @@ import uuid
import json
import asyncio
import time
import os
from fastapi import APIRouter, Request, Body, status, HTTPException, Response, BackgroundTasks
from fastapi.responses import JSONResponse
from fastapi.responses import StreamingResponse
from fastapi.responses import JSONResponse, HTMLResponse
from fastapi.responses import StreamingResponse, FileResponse
from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from sse_starlette.sse import EventSourceResponse
from typing import List
@ -34,7 +34,7 @@ knowledge_service = KnowledgeService()
model_semaphore = None
global_counter = 0
static_file_path = os.path.join(os.getcwd(), "server/static")
async def validation_exception_handler(request: Request, exc: RequestValidationError):
message = ""
@ -82,6 +82,9 @@ def knowledge_list():
params.update({space.name: space.name})
return params
@router.get("/")
async def read_main():
return FileResponse(f"{static_file_path}/test.html")
@router.get("/v1/chat/dialogue/list", response_model=Result[ConversationVo])

View File

@ -55,7 +55,6 @@ app.add_middleware(
)
app.mount("/static", StaticFiles(directory=static_file_path), name="static")
app.add_route("/test", "static/test.html")
app.include_router(api_v1)
app.add_exception_handler(RequestValidationError, validation_exception_handler)

View File

@ -6,7 +6,7 @@
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div id="output"></div>
<div id="output">Hello World! I'm DB-GPT!</div>
<script>
$(document).ready(function() {
var source = new EventSource("/v1/chat/completions");