Vitrous commited on
Commit
92d318e
·
verified ·
1 Parent(s): cb06e39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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
- generated_text = pipe(persona_desc + user_prompt)[0]['generated_text']
101
- assistant_response = generated_text.replace("ASSISTANT:", "").strip()
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('/start_conversation/')
119
- async def start_conversation(request: Request):
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('/custom_prompted_chat/')
147
- async def start_chat(request: Request):
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