How to write similar document using examples? #9245
Replies: 6 comments 4 replies
-
🤖 To develop a writing assistant using LangChain that can generate a document like a divorce agreement by summarizing key points from example documents, asking the user questions based on these points, and collecting the user's responses, you can follow these steps:
template = """You are an AI trained to summarize key points from documents.
Given the following document, please generate a summary based on that document.
Example Format:
<Begin Document>
...
<End Document>
SUMMARY: summary here
The summary should be concise and be based explicitly on information in the document. Begin!
<Begin Document>
{doc}
<End Document>"""
PROMPT = PromptTemplate(
input_variables=["doc"],
template=template,
)
For the chatbot interaction, you can override the Please note that this is a simplified example and the actual implementation would involve more complex logic to handle multiple questions and responses, and to generate a coherent final document. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
🤖 Hello, Based on your requirements, you can use LangChain to develop a writing assistant that can generate a document like a divorce agreement by summarizing key points from example documents, asking the user questions based on these points, and collecting the user's responses. Here's a step-by-step guide on how you can achieve this:
from langchain.prompts import PromptTemplate
# Summarize key points from example documents
example_prompt = PromptTemplate(
template="Content: {page_content}\nSource: {source}",
input_variables=["page_content", "source"],
)
summary = example_prompt.fill({"page_content": example_document_content, "source": "example_document_source"})
# Ask user questions based on these points
question_prompt = PromptTemplate(
template=question_prompt_template, input_variables=["context", "question"]
)
question = question_prompt.fill({"context": summary, "question": "What is your spouse's name?"})
# Collect user's responses
user_response = input(question)
# Generate the final document
combine_prompt = PromptTemplate(
template=combine_prompt_template, input_variables=["summaries", "question"]
)
final_document = combine_prompt.fill({"summaries": user_response, "question": "What is your spouse's name?"}) Please note that this is a simplified example and the actual implementation would involve more complex logic to handle multiple questions and responses, and to generate a coherent final document. For the chatbot-like interaction, you can override the I hope this helps! If you have any other questions, feel free to ask. Best, Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
I think Dosu's answers are not quite right. I think at least it needs three steps:
|
Beta Was this translation helpful? Give feedback.
-
I think this problem is interesting, anyone else interested? |
Beta Was this translation helpful? Give feedback.
-
Hi! This is a very interesting topic. We're working on a document generation use case. We aim to offer a chat interface to users can modify the document in real time, after an initial draft is generated. We're struggling finding the best way to do this and would love to hear ideas and real-life experiences. Here's a diagram of what we're thinking so far: Basically:
We're in validation stage and would appreciate any input. |
Beta Was this translation helpful? Give feedback.
-
@qingtian1771 were you able to find the solution to your usecase. I am looking for something similar. It will be good know the full solution. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Following is concreate requirements:
Maybe user can do this through a chatbot like following:
User: I want to write a divorce agreement.
AI: Wait a moment, I will ask you some questions, could you please answer following questions:
.....
Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions