Update app.py
Browse files
app.py
CHANGED
@@ -96,9 +96,10 @@ def generate_prompt_response(persona_desc: str, msg_prompt: str) -> dict:
|
|
96 |
top_k=40,
|
97 |
repetition_penalty=1.1
|
98 |
)
|
|
|
99 |
|
100 |
-
|
101 |
-
assistant_response =
|
102 |
|
103 |
return {"user": msg_prompt, "assistant": assistant_response}
|
104 |
|
@@ -115,8 +116,8 @@ async def api_home():
|
|
115 |
"""
|
116 |
return {'detail': 'Welcome to Articko Bot!'}
|
117 |
|
118 |
-
@app.post('/
|
119 |
-
async def
|
120 |
"""
|
121 |
Starts a new conversation thread with a provided prompt.
|
122 |
|
@@ -143,8 +144,8 @@ async def start_conversation(request: Request):
|
|
143 |
except Exception as e:
|
144 |
raise HTTPException(status_code=500, detail=str(e))
|
145 |
|
146 |
-
@app.post('/
|
147 |
-
async def
|
148 |
"""
|
149 |
Starts a new chat thread with a provided user message prompt and persona description of the ai assistant .
|
150 |
|
|
|
96 |
top_k=40,
|
97 |
repetition_penalty=1.1
|
98 |
)
|
99 |
+
prompt_template = (persona_desc + user_prompt)
|
100 |
|
101 |
+
generated_response = pipe(prompt_template)[0]['generated_text']
|
102 |
+
assistant_response = generated_response.split('\n\n')[1]
|
103 |
|
104 |
return {"user": msg_prompt, "assistant": assistant_response}
|
105 |
|
|
|
116 |
"""
|
117 |
return {'detail': 'Welcome to Articko Bot!'}
|
118 |
|
119 |
+
@app.post('/chat')
|
120 |
+
async def chat(request: Request):
|
121 |
"""
|
122 |
Starts a new conversation thread with a provided prompt.
|
123 |
|
|
|
144 |
except Exception as e:
|
145 |
raise HTTPException(status_code=500, detail=str(e))
|
146 |
|
147 |
+
@app.post('/prompted_chat')
|
148 |
+
async def prompted_chat(request: Request):
|
149 |
"""
|
150 |
Starts a new chat thread with a provided user message prompt and persona description of the ai assistant .
|
151 |
|