MCPcopy Create free account
hub / github.com/InternLM/Tutorial / combine_history

Function combine_history

tools/xtuner_streamlit_demo.py:199–213  ·  view source on GitHub ↗
(prompt)

Source from the content-addressed store, hash-verified

197
198
199def combine_history(prompt):
200 messages = st.session_state.messages
201 meta_instruction = ('')
202 total_prompt = f"<s><|im_start|>system\n{meta_instruction}<|im_end|>\n"
203 for message in messages:
204 cur_content = message['content']
205 if message['role'] == 'user':
206 cur_prompt = user_prompt.format(user=cur_content)
207 elif message['role'] == 'robot':
208 cur_prompt = robot_prompt.format(robot=cur_content)
209 else:
210 raise RuntimeError
211 total_prompt += cur_prompt
212 total_prompt = total_prompt + cur_query_prompt.format(user=prompt)
213 return total_prompt
214
215
216def main():

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected