Create Questions and Answers from Documents
The system extracts the content from a source file (such as a PDF or DOCX stored on Google Drive), receives the desired number of questions as a parameter, and uses an AI model (OpenAI) to generate a relevant questionnaire with its answers.
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
GDriveFilesComponent-vtobb[<div><img src="/_astro/google_drive.wKmDsV2c.svg" style="height: 20px !important;width: 20px !important"/></div>Google Drive File Manager]
style GDriveFilesComponent-vtobb stroke:#a170ff
ParseData-orp1r[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Parse Data]
style ParseData-orp1r stroke:#a170ff
LanggraphReactAgent-crvmw[Agent]
style LanggraphReactAgent-crvmw stroke:#a170ff
ChatOutput-iwxt1[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output]
style ChatOutput-iwxt1 stroke:#a170ff
OpenAIModel-7glfi[<div><img src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI]
style OpenAIModel-7glfi stroke:#a170ff
GDriveFilesComponent-vtobb -.- ParseData-orp1r
linkStyle 0 stroke:#a170ff
ParseData-orp1r -.- LanggraphReactAgent-crvmw
linkStyle 1 stroke:#a170ff
OpenAIModel-7glfi -.- LanggraphReactAgent-crvmw
linkStyle 2 stroke:#a170ff
LanggraphReactAgent-crvmw -.- ChatOutput-iwxt1
linkStyle 3 stroke:#a170ff
Create Questions and Answers from Documents
đź§© Overview
This workflow extracts text from a document stored on Google Drive, converts the extracted content into plain text, and then uses an OpenAI language model to generate a set of relevant questions and answers based on that content. The process automates the creation of customized quizzes, saving time for educators and content creators.
⚙️ Main Features
- Retrieves and decodes files from Google Drive using a simple file‑selection interface.
- Parses binary or text data into human‑readable text with a customizable template.
- Feeds the parsed text to a pre‑built Langgraph React agent that orchestrates the LLM.
- Employs the GPT‑4o‑mini model to generate a structured Q&A set following a system prompt.
- Streams the final response into a chat‑style output for immediate review.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Google Drive File Manager | Retrieves the selected document from Google Drive and provides its raw content. | File identifier or selection, operation (e.g., Get). | File content (binary or text). |
| Parse Data | Converts the raw file content into plain text using a user‑defined template. | Raw file content. | Formatted text. |
| Agent | Orchestrates the language‑model interaction, applying the system prompt and handling memory. | Formatted text (as input message). | Generated Q&A response. |
| OpenAI Model | Generates the answer text based on the agent’s prompt and input. | Input message (formatted text). | Text output. |
| Chat Output | Displays the generated Q&A set in a chat interface for the user. | Generated response message. | Visible chat message. |
đź§ Notes
- The workflow relies on a Google Drive API connection; the user must provide credentials that grant read access to the target file.
- The OpenAI Model component uses the GPT‑4o‑mini variant; the model name can be swapped for other OpenAI models if higher‑quality output is required.
- The Parse Data step can be customized with a different template or separator, but the default configuration assumes the file’s textual content is already structured.
- The Agent is configured with a system prompt that instructs the model to generate questions and answers. Adjusting the prompt or the number of iterations can influence the length and depth of the output.
- Memory and streaming are disabled by default; enabling these features will increase resource usage but can provide a more interactive experience.
- All components operate in a stateless manner except for the agent’s short‑term memory, which is reset between workflow executions unless persistent storage is explicitly configured.