Update app.py
Browse files
app.py
CHANGED
@@ -75,7 +75,7 @@ def hermes_model():
|
|
75 |
|
76 |
model, tokenizer = hermes_model()
|
77 |
|
78 |
-
def
|
79 |
"""
|
80 |
Generates a response from the model given a prompt.
|
81 |
|
@@ -107,7 +107,7 @@ def hermes_generate_response(msg_prompt: str) -> dict:
|
|
107 |
|
108 |
|
109 |
|
110 |
-
def
|
111 |
"""
|
112 |
Generates a response based on the provided persona description prompt and user message prompt.
|
113 |
|
@@ -137,7 +137,7 @@ def hermes_prompt_response(instructions_prompt: str, msg_prompt: str) -> dict:
|
|
137 |
|
138 |
# Construct the prompt template
|
139 |
prompt_template=f'''<|im_start|>system
|
140 |
-
{
|
141 |
<|im_start|>user
|
142 |
{msg_prompt}<|im_end|>
|
143 |
<|im_start|>assistant
|
@@ -194,7 +194,7 @@ async def hermes_chat(request: Request):
|
|
194 |
|
195 |
if not msg_prompt:
|
196 |
raise HTTPException(status_code=400, detail="No prompt provided")
|
197 |
-
response =
|
198 |
thread_id = len(conversations) + 1
|
199 |
conversations[thread_id] = {'prompt': msg_prompt, 'responses': [response]}
|
200 |
return {'thread_id': thread_id, 'response': response}
|
@@ -222,7 +222,7 @@ async def prompted_chat(request: Request):
|
|
222 |
if not msg_prompt or not persona_desc:
|
223 |
raise HTTPException(status_code=400, detail="Both prompt and person_description are required")
|
224 |
|
225 |
-
response =
|
226 |
|
227 |
thread_id = len(conversations) + 1
|
228 |
conversations[thread_id] = {'prompt': msg_prompt, 'responses': [response]}
|
|
|
75 |
|
76 |
model, tokenizer = hermes_model()
|
77 |
|
78 |
+
def chat_response(msg_prompt: str) -> dict:
|
79 |
"""
|
80 |
Generates a response from the model given a prompt.
|
81 |
|
|
|
107 |
|
108 |
|
109 |
|
110 |
+
def prompt_response(instructions_prompt: str, msg_prompt: str) -> dict:
|
111 |
"""
|
112 |
Generates a response based on the provided persona description prompt and user message prompt.
|
113 |
|
|
|
137 |
|
138 |
# Construct the prompt template
|
139 |
prompt_template=f'''<|im_start|>system
|
140 |
+
{instructions_prompt}<|im_end|>
|
141 |
<|im_start|>user
|
142 |
{msg_prompt}<|im_end|>
|
143 |
<|im_start|>assistant
|
|
|
194 |
|
195 |
if not msg_prompt:
|
196 |
raise HTTPException(status_code=400, detail="No prompt provided")
|
197 |
+
response = chat_response(msg_prompt)
|
198 |
thread_id = len(conversations) + 1
|
199 |
conversations[thread_id] = {'prompt': msg_prompt, 'responses': [response]}
|
200 |
return {'thread_id': thread_id, 'response': response}
|
|
|
222 |
if not msg_prompt or not persona_desc:
|
223 |
raise HTTPException(status_code=400, detail="Both prompt and person_description are required")
|
224 |
|
225 |
+
response = prompt_response(persona_desc, msg_prompt)
|
226 |
|
227 |
thread_id = len(conversations) + 1
|
228 |
conversations[thread_id] = {'prompt': msg_prompt, 'responses': [response]}
|