| 34 | |
| 35 | @cl.on_chat_start |
| 36 | def main(): |
| 37 | template = """### System Prompt |
| 38 | The following is a friendly conversation between a human and an AI optimized to generate source-code. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know: |
| 39 | |
| 40 | ### Current conversation: |
| 41 | {history} |
| 42 | |
| 43 | ### User Message |
| 44 | {input} |
| 45 | |
| 46 | ### Assistant""" |
| 47 | |
| 48 | prompt = PromptTemplate(template=template, input_variables=["history", "input"]) |
| 49 | |
| 50 | conversation = ConversationChain( |
| 51 | prompt=prompt, llm=llm, memory=ConversationBufferWindowMemory(k=10) |
| 52 | ) |
| 53 | |
| 54 | cl.user_session.set("conv_chain", conversation) |
| 55 | |
| 56 | |
| 57 | @cl.on_message |