MCPcopy Index your code
hub / github.com/InternLM/Tutorial / combine_history

Function combine_history

tools/streamlit_demo.py:216–232  ·  view source on GitHub ↗
(prompt)

Source from the content-addressed store, hash-verified

214
215
216def combine_history(prompt):
217 messages = st.session_state.messages
218 meta_instruction = ('You are InternLM (书生·浦语), a helpful, honest, '
219 'and harmless AI assistant developed by Shanghai '
220 'AI Laboratory (上海人工智能实验室).')
221 total_prompt = f'<s><|im_start|>system\n{meta_instruction}<|im_end|>\n'
222 for message in messages:
223 cur_content = message['content']
224 if message['role'] == 'user':
225 cur_prompt = user_prompt.format(user=cur_content)
226 elif message['role'] == 'robot':
227 cur_prompt = robot_prompt.format(robot=cur_content)
228 else:
229 raise RuntimeError
230 total_prompt += cur_prompt
231 total_prompt = total_prompt + cur_query_prompt.format(user=prompt)
232 return total_prompt
233
234
235def main():

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected