(llm, question)
| 50 | |
| 51 | |
| 52 | def ChatBot(llm, question): |
| 53 | # Define the prompt template |
| 54 | template = """ |
| 55 | {question} |
| 56 | you reply json in {{ reply:"<content>" }} |
| 57 | """ |
| 58 | |
| 59 | prompt = PromptTemplate.from_template(clip_history(template)) |
| 60 | |
| 61 | # Format the prompt with the input variable |
| 62 | formatted_prompt = prompt.format(question=question) |
| 63 | |
| 64 | llm_chain = prompt | llm | StrOutputParser() |
| 65 | generation = llm_chain.invoke(formatted_prompt) |
| 66 | |
| 67 | data = json.loads(generation) |
| 68 | reply = data.get("reply", "") |
| 69 | |
| 70 | return reply |
| 71 | |
| 72 | |
| 73 | def create_llm_chain(prompt_template: str, llm, history: str) -> str: |
no test coverage detected