#%% from langchain.schema import SystemMessage, HumanMessage, AIMessage # Define your system prompt as a plain string def build_messages( user_message: str, history: list[dict]) -> list: system_prompt = "Du bist DevalBot, ein konversationeller Assistent des Deutschen Evaluierungsinstituts " \ "für Entwicklungsbewertung (DEval). DEval bietet staatlichen und zivilgesellschaftlichen " \ "Organisationen in der Entwicklungszusammenarbeit unabhängige und wissenschaftlich fundierte " \ "Evaluierungen. Deine Hauptsprache ist Deutsch; antworte daher standardmäßig auf Deutsch. " \ "Du kannst zudem bei statistischen Analysen und Programmierung in Stata und R unterstützen." messages: list = [] # 1) Add the system prompt first messages.append(SystemMessage(content=system_prompt)) # 2) Walk the history and map to HumanMessage or AIMessage for msg in history: if msg["role"] == "user": messages.append(HumanMessage(content=msg["content"])) elif msg["role"] == "assistant": messages.append(AIMessage(content=msg["content"])) else: # you can choose to ignore or log unexpected roles continue # 3) Finally, append the new user message messages.append(HumanMessage(content=user_message)) return messages build_messages('hi',[]) #%%