mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
upgraded
This commit is contained in:
parent
88c1e1593d
commit
78726cff5d
11
app.py
11
app.py
@ -29,9 +29,11 @@ from fastapi import FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from pydantic import ValidationError
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import socket
|
||||
import psutil
|
||||
|
||||
|
||||
def get_ip_addresses():
|
||||
hostname = socket.gethostname()
|
||||
ip_addresses = [socket.gethostbyname(hostname)]
|
||||
@ -89,6 +91,15 @@ if __name__ == "__main__":
|
||||
else:
|
||||
config.allowed_origins += [f"https://{ip}:{config['port']}" if is_https else f"http://{ip}:{config['port']}" for ip in get_ip_addresses()]
|
||||
allowed_origins = config.allowed_origins+[f"https://localhost:{config['port']}" if is_https else f"http://localhost:{config['port']}"]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=allowed_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=allowed_origins, ping_timeout=1200, ping_interval=30) # Enable CORS for selected origins
|
||||
|
||||
LOLLMSWebUI.build_instance(config=config, lollms_paths=lollms_paths, args=args, sio=sio)
|
||||
|
@ -124,15 +124,23 @@ async def add_webpage(request: AddWebPageRequest):
|
||||
client = lollmsElfServer.session.get_client(request.client_id)
|
||||
url = request.url
|
||||
index = find_first_available_file_index(lollmsElfServer.lollms_paths.personal_uploads_path,"web_",".txt")
|
||||
file_path=sanitize_path(lollmsElfServer.lollms_paths.personal_uploads_path/f"web_{index}.txt",True)
|
||||
try:
|
||||
file_path=sanitize_path(lollmsElfServer.lollms_paths.personal_uploads_path/f"web_{index}.txt",True)
|
||||
except Exception as ex:
|
||||
lollmsElfServer.HideBlockingMessage()
|
||||
raise ex
|
||||
try:
|
||||
result = urlparse(url)
|
||||
if all([result.scheme, result.netloc]): # valid URL
|
||||
if scrape_and_save(url=url, file_path=file_path,max_size=MAX_PAGE_SIZE):
|
||||
if not scrape_and_save(url=url, file_path=file_path,max_size=MAX_PAGE_SIZE):
|
||||
lollmsElfServer.HideBlockingMessage()
|
||||
raise HTTPException(status_code=400, detail="Web page too large")
|
||||
else:
|
||||
lollmsElfServer.HideBlockingMessage()
|
||||
raise HTTPException(status_code=400, detail="Invalid URL")
|
||||
except Exception as e:
|
||||
trace_exception(e)
|
||||
lollmsElfServer.HideBlockingMessage()
|
||||
raise HTTPException(status_code=400, detail=f"Exception : {e}")
|
||||
|
||||
try:
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
web/dist/index.html
vendored
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LoLLMS WebUI - Welcome</title>
|
||||
<script type="module" crossorigin src="/assets/index-17e2ac3f.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-ff245394.css">
|
||||
<script type="module" crossorigin src="/assets/index-2e9957ed.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-f60ab000.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -4964,6 +4964,7 @@ export default {
|
||||
onPersonalityReinstall(persItem){
|
||||
console.log('on reinstall ', persItem)
|
||||
this.isLoading = true
|
||||
console.log("Personality path:",persItem.personality.path)
|
||||
axios.post('/reinstall_personality', { name: persItem.personality.path }).then((res) => {
|
||||
|
||||
if (res) {
|
||||
|
Loading…
Reference in New Issue
Block a user