Views
No views yet
prompt_model function provided below demonstrates how the llama2 prompting method is implemented:1def prompt_model(
2 message: str,
3 chat_history: Optional[List[str] | List[List[str]]] = None,
4 system_prompt: Optional[str] = None
5):
6 if chat_history is None:
7 chat_history = []
8 system = f"<|system|>\n{system_prompt}</s>" if system_prompt is not None else ""
9 ua = ""
10 for user_input, response in chat_history:
11 ua += f"<|user|>\n{user_input}</s>\n" + f"<|assistant|>\n{response}</s>\n"
12 return system + ua + f"<|user|>\n{message}</s>\n<|assistant|>\n"prompt_model function takes a message as input, along with the chat_history and system_prompt. It generates a formatted text that includes the system prompt, user inputs, and the current message. This approach allows LinguaMatic to maintain context and provide more coherent and context-aware responses.