File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change 66
77import redis
88import uvicorn
9- from fastapi import Depends , FastAPI
9+ from fastapi import Body , Depends , FastAPI
1010from fastapi .middleware .cors import CORSMiddleware
1111
1212# from fastapi.responses import HTMLResponse
@@ -81,6 +81,37 @@ def read_root():
8181# self.conversation = Conversation()
8282
8383
84+ @app .get ("/prompt" )
85+ def get_prompt ():
86+ """
87+ 前端获取提示语
88+ """
89+ prompt_base_chat = Prompt .base_prompt_chat
90+ prompt_base_query = Prompt .base_prompt_query
91+ prompt = {"promptBaseChat" : prompt_base_chat , "promptBaseQuery" : prompt_base_query }
92+ return {"code" : 200 , "data" : prompt }
93+
94+
95+ @app .post ("/promptUpdate" )
96+ def update_prompt (prompt : str = Body (...), prompt_type : int = Body (...)):
97+ """
98+ 前端更新提示语
99+ """
100+ print (prompt )
101+ try :
102+ if prompt_type == 1 :
103+ prompt_base_chat = prompt
104+ Prompt .base_prompt_chat = prompt_base_chat
105+ elif prompt_type == 0 :
106+ prompt_base_query = prompt
107+ Prompt .base_prompt_query = prompt_base_query
108+ else :
109+ return {"code" : 501 , "data" : "Error: promptType error!" }
110+ return {"code" : 200 , "data" : "success" }
111+ except Exception as e :
112+ return {"code" : 502 , "data" : "Error: " + str (e )}
113+
114+
84115@app .get ("/chat" )
85116async def chat_stream (input : Optional [str ] = None ) -> EventSourceResponse :
86117 """
You can’t perform that action at this time.
0 commit comments