File tree 1 file changed +32
-1
lines changed
1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import redis
8
8
import uvicorn
9
- from fastapi import Depends , FastAPI
9
+ from fastapi import Body , Depends , FastAPI
10
10
from fastapi .middleware .cors import CORSMiddleware
11
11
12
12
# from fastapi.responses import HTMLResponse
@@ -81,6 +81,37 @@ def read_root():
81
81
# self.conversation = Conversation()
82
82
83
83
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
+
84
115
@app .get ("/chat" )
85
116
async def chat_stream (input : Optional [str ] = None ) -> EventSourceResponse :
86
117
"""
You can’t perform that action at this time.
0 commit comments