├── .gitignore ├── LICENSE ├── Pages └── browse_data.py ├── README.md ├── basic_chain.py ├── data ├── basal_calories.txt ├── carbcalcounts.txt ├── in_season.txt ├── mealplan.txt └── walocal.txt ├── ensemble.py ├── examples ├── grocery.md ├── healthy_meal_10_tips.pdf ├── mal_boole.pdf ├── nutrients_csvfile.csv └── us_army_recipes.txt ├── filter.py ├── full_chain.py ├── local_loader.py ├── memory.py ├── packages.txt ├── rag_chain.py ├── remote_loader.py ├── requirements.txt ├── run_all_mains.sh ├── splitter.py ├── streamlit_app.py └── vector_store.py /.gitignore: -------------------------------------------------------------------------------- 1 | .venv/ 2 | __pycache__/ 3 | .DS_Store 4 | .streamlit/ 5 | .env 6 | .idea/ 7 | .python-version 8 | store/ 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Pages/browse_data.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | 3 | from local_loader import list_txt_files 4 | 5 | paths = list(list_txt_files()) 6 | 7 | file_path = st.selectbox("Select a data file to view", paths, index=None) 8 | 9 | if file_path: 10 | with open(file_path,"r") as f: 11 | md_content = f.read() 12 | st.markdown(md_content) 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # LangChain and Streamlit RAG 3 | 4 | ## Demo App on Community Cloud 5 | 6 | [![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://st-lc-rag.streamlit.app/) 7 | 8 | 9 | ## Quickstart 10 | 11 | ### Setup Python environment 12 | 13 | The Python version used when this was developed was 3.10.13 14 | 15 | 16 | ```bash 17 | python -mvenv .venv 18 | source .venv/bin/activate 19 | pip install -U pip 20 | pip install -r requirements.txt 21 | ``` 22 | 23 | ### Setup .env file with API tokens needed. 24 | 25 | ``` 26 | OPENAI_API_KEY="" 27 | HUGGINGFACEHUB_API_TOKEN="" 28 | ``` 29 | 30 | ### Setup Streamlit app secrets. 31 | 32 | #### 1. Set up the .streamlit directory and secrets file. 33 | 34 | ```bash 35 | mkdir .streamlit 36 | touch .streamlit/secrets.toml 37 | chmod 0600 .streamlit/secrets.toml 38 | ``` 39 | 40 | #### 2. Edit secrets.toml 41 | 42 | **Either edit `secrets.toml` in you favorite editor.** 43 | 44 | ```toml 45 | OPENAI_API_KEY="" 46 | HUGGINGFACEHUB_API_TOKEN="" 47 | ``` 48 | 49 | **Or, you can just reuse .env contents from above.** 50 | 51 | ```bash 52 | cat < .env >> .streamlit/secrets.toml 53 | ``` 54 | 55 | ### Verify Environment 56 | 57 | 1. Check that LangChain dependencies are working. 58 | 59 | ```bash 60 | python basic_chain.py 61 | ``` 62 | 63 | 2. Check that Streamlit and dependencies are working. 64 | 65 | ```bash 66 | streamlit run streamlit_app.py 67 | ``` 68 | 69 | 3. Run Individual Example Programs 70 | 71 | The most of the Python source files besides `streamlit_app.py` have a main defined 72 | so that you can execute them directly as an example or test. 73 | 74 | For example, the main in `ensemble.py` will use context from an online version of the book [*The Problems of Philosophy* by Bertrand Russell](https://www.gutenberg.org/ebooks/5827.html.images) 75 | to answer "What are the key problems of philosophy according to Russell?" 76 | 77 | ```bash 78 | python ensemble.py 79 | ``` 80 | 81 | > Split into 313 chunks 82 | > According to Russell, the key problems of philosophy include the uncertainty of knowledge, the limitations of metaphysical reasoning, and the inability to provide definite answers to fundamental questions. Philosophy aims to diminish the risk of error, but cannot eliminate it entirely due to human fallibility. The value of philosophy lies in its ability to challenge common sense beliefs and lead to the exploration of complex problems. 83 | 84 | 85 | 86 | ## Example Queries for Streamlit App 87 | 88 | ### Example 1: Metabolic Rate 89 | 90 | **Question:** 91 | If I am an 195 lb male, what should my calorie intake be to lose 1 lb a week based on what you know about my basal metabolic rate? 92 | 93 | **Answer:** 94 | To calculate the calorie intake for a 195 lb male to lose 1 lb per week based on their basal metabolic rate, we can use the estimated BMR values provided in the context. 95 | 96 | For a 190 lb male, the estimated BMR is around 2,280 calories per day. To lose 1 lb per week, a general rule of thumb is to create a calorie deficit of about 500 calories per day. 97 | 98 | Therefore, to lose 1 lb per week, a 195 lb male should aim to consume around 1,780 calories per day (2,280 calories - 500 calories). This calorie intake, combined with regular physical activity, can help achieve a sustainable weight loss goal. 99 | 100 | ### Example 2: Recipes 101 | 102 | NOTE: to use this example, copy the `example/us_army_recipes.txt` file into the `data` directory. It is left out by default because it significantly increases the resources used over the other examples. 103 | 104 | **Question:** 105 | How do I make salmon croquettes according to the recipes I provided you? 106 | 107 | **Answer:** 108 | To make salmon croquettes based on the recipes shared, you can follow these steps: 109 | 110 | Ingredients: 111 | 112 | - 4 cans of salmon 113 | - 4 pounds of cold boiled potatoes 114 | - 2 eggs 115 | - Salt and pepper to taste 116 | - Cracker dust for coating 117 | - Oil for frying 118 | 119 | Instructions: 120 | 121 | 1. Drain the canned salmon and remove any bones or skin. 122 | 2. In a large bowl, mash the salmon and boiled potatoes together. 123 | 3. Add the eggs, salt, and pepper to the mixture and combine well. 124 | 4. Shape the mixture into small cakes about 2 inches in diameter. 125 | 5. In a separate bowl, beat the remaining eggs with a little milk to create an egg batter. 126 | 6. Dip each salmon cake into the egg batter, then coat it with cracker dust. 127 | 7. Heat oil in a pan for frying. 128 | 8. Fry the salmon croquettes in the hot oil until they are golden brown on all sides. 129 | 9. Once cooked, remove them from the oil and place them on a paper towel to drain any excess oil. 130 | 10. Serve the salmon croquettes hot and enjoy! 131 | 132 | I hope these instructions help you make delicious salmon croquettes! Let me know if you need any more assistance. 133 | 134 | 135 | ## Example Data Used 136 | 137 | * The file `examples/nutrients_csvfile.csv` is from the Kaggle Dataset [Nutritional Facts for most common foods](https://www.kaggle.com/datasets/niharika41298/nutrition-details-for-most-common-foods/) 138 | shared under the [CC0: Public Domain](https://creativecommons.org/publicdomain/zero/1.0/) license. 139 | * The file `examples/us_army_recipes.txt` is in the public domain, and was retrieved from Project Gutenberg at [Recipes Used in the Cooking Schools, U. S. Army by United States. Army](https://www.gutenberg.org/ebooks/65250). 140 | * The file `examples/healthy_meal_10_tips.pdf` was published by thes USDA, Center for Nutrition Policy and Promotion and was retrieved from Wikimedia Commons, and is in the public domain. 141 | [See page for author, Public domain, via Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Build_a_healthy_meal_10_tips_for_healthy_meals_(IA_CAT31299650).pdf). 142 | * The file `examples/mal_boole.pdf` is in the public domain. Boole, G. (1847, January 1). The Mathematical Analysis of Logic. Retrieved from Project Gutenberg at https://www.gutenberg.org/ebooks/36884. 143 | * The file `examples/grocery.md` is just a grocery list. 144 | 145 | ## References 146 | 147 | 148 | Gordon V. Cormack, Charles L A Clarke, and Stefan Buettcher. 2009. [Reciprocal rank fusion outperforms condorcet and individual rank learning methods](https://dl.acm.org/doi/10.1145/1571941.1572114). In Proceedings of the 32nd international ACM SIGIR conference on Research and development in information retrieval (SIGIR '09). Association for Computing Machinery, New York, NY, USA, 758–759. . 149 | 150 | Jiang, A. Q., Sablayrolles, A., Mensch, A., Bamford, C., Singh Chaplot, D., de las Casas, D., … & El Sayed, W. (2023). [Mistral 7B](https://arxiv.org/abs/2310.06825). arXiv e-prints, arXiv-2310. . 151 | 152 | Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., … & Kiela, D. (2020). [Retrieval-augmented generation for knowledge-intensive nlp tasks](https://arxiv.org/abs/2005.11401). Advances in Neural Information Processing Systems, 33, 9459–9474. 153 | 154 | Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., & Liang, P. (2024). [Lost in the middle: How language models use long contexts](https://arxiv.org/abs/2307.03172). Transactions of the Association for Computational Linguistics, 12, 157–173. 155 | 156 | Robertson, S., & Zaragoza, H. (2009). [The probabilistic relevance framework: BM25 and beyond](https://dl.acm.org/doi/10.1561/1500000019). Foundations and Trends® in Information Retrieval, 3(4), 333–389. 157 | 158 | Thibault Formal, Benjamin Piwowarski, and Stéphane Clinchant. 2021. [SPLADE: Sparse Lexical and Expansion Model for First Stage Ranking](https://dl.acm.org/doi/10.1145/3404835.3463098). In Proceedings of the 44th International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR '21). Association for Computing Machinery, New York, NY, USA, 2288–2292. . 159 | 160 | Tunstall, L., Beeching, E., Lambert, N., Rajani, N., Rasul, K., Belkada, Y., … & Wolf, T. (2023). Zephyr: Direct Distillation of LM Alignment. arXiv e-prints, arXiv-2310. . 161 | 162 | ## Misc Notes 163 | 164 | - There is an issue with newer langchain package versions and streamlit chat history, see https://github.com/langchain-ai/langchain/pull/18834 165 | - This one reason why a number of dependencies are pinned to specific values. -------------------------------------------------------------------------------- /basic_chain.py: -------------------------------------------------------------------------------- 1 | from langchain_core.output_parsers import StrOutputParser 2 | from langchain_core.prompts import ChatPromptTemplate 3 | from langchain_openai import ChatOpenAI 4 | from langchain_community.llms import HuggingFaceHub 5 | from langchain_community.chat_models.huggingface import ChatHuggingFace 6 | 7 | from dotenv import load_dotenv 8 | 9 | 10 | MISTRAL_ID = "mistralai/Mistral-7B-Instruct-v0.1" 11 | ZEPHYR_ID = "HuggingFaceH4/zephyr-7b-beta" 12 | 13 | 14 | def get_model(repo_id=ZEPHYR_ID, **kwargs): 15 | if repo_id == "ChatGPT": 16 | chat_model = ChatOpenAI(temperature=0, **kwargs) 17 | else: 18 | huggingfacehub_api_token = kwargs.get("HUGGINGFACEHUB_API_TOKEN", None) 19 | llm = HuggingFaceHub( 20 | repo_id=repo_id, 21 | huggingfacehub_api_token=huggingfacehub_api_token, 22 | task="text-generation", 23 | model_kwargs={ 24 | "max_new_tokens": 512, 25 | "top_k": 30, 26 | "temperature": 0.1, 27 | "repetition_penalty": 1.03, 28 | }) 29 | chat_model = ChatHuggingFace(llm=llm) 30 | return chat_model 31 | 32 | 33 | def basic_chain(model=None, prompt=None): 34 | if not model: 35 | model = get_model() 36 | if not prompt: 37 | prompt = ChatPromptTemplate.from_template("Tell me the most noteworthy books by the author {author}") 38 | 39 | chain = prompt | model 40 | return chain 41 | 42 | 43 | def main(): 44 | load_dotenv() 45 | 46 | prompt = ChatPromptTemplate.from_template("Tell me the most noteworthy books by the author {author}") 47 | chain = basic_chain(prompt=prompt) | StrOutputParser() 48 | 49 | results = chain.invoke({"author": "William Faulkner"}) 50 | print(results) 51 | 52 | 53 | if __name__ == '__main__': 54 | main() 55 | -------------------------------------------------------------------------------- /data/basal_calories.txt: -------------------------------------------------------------------------------- 1 | ### Basal Metabolic Rate by Weight and Birth Gender 2 | 3 | Basal metabolic rate (BMR) varies by gender, weight, and age. Here's a general estimate of typical daily basal calorie requirements for adults by birth gender (male and female) and by weight in increments of 10 pounds from 100 to 250 lbs. Please note that these are rough estimates, and individual BMR can vary based on factors like muscle mass, activity level, and genetics. These values assume a sedentary lifestyle: 4 | 5 | **Male:** 6 | 7 | - 100 lbs: ~1,200 calories 8 | - 110 lbs: ~1,320 calories 9 | - 120 lbs: ~1,440 calories 10 | - 130 lbs: ~1,560 calories 11 | - 140 lbs: ~1,680 calories 12 | - 150 lbs: ~1,800 calories 13 | - 160 lbs: ~1,920 calories 14 | - 170 lbs: ~2,040 calories 15 | - 180 lbs: ~2,160 calories 16 | - 190 lbs: ~2,280 calories 17 | - 200 lbs: ~2,400 calories 18 | - 210 lbs: ~2,520 calories 19 | - 220 lbs: ~2,640 calories 20 | - 230 lbs: ~2,760 calories 21 | - 240 lbs: ~2,880 calories 22 | - 250 lbs: ~3,000 calories 23 | 24 | **Female:** 25 | 26 | - 100 lbs: ~1,000 calories 27 | - 110 lbs: ~1,100 calories 28 | - 120 lbs: ~1,200 calories 29 | - 130 lbs: ~1,300 calories 30 | - 140 lbs: ~1,400 calories 31 | - 150 lbs: ~1,500 calories 32 | - 160 lbs: ~1,600 calories 33 | - 170 lbs: ~1,700 calories 34 | - 180 lbs: ~1,800 calories 35 | - 190 lbs: ~1,900 calories 36 | - 200 lbs: ~2,000 calories 37 | - 210 lbs: ~2,100 calories 38 | - 220 lbs: ~2,200 calories 39 | - 230 lbs: ~2,300 calories 40 | - 240 lbs: ~2,400 calories 41 | - 250 lbs: ~2,500 calories 42 | 43 | Again, these are just rough estimates. To get a more accurate picture of your daily calorie needs, it's best to consult with a registered dietitian or use a BMR calculator that takes into account more detailed information about your individual characteristics and activity level. 44 | -------------------------------------------------------------------------------- /data/carbcalcounts.txt: -------------------------------------------------------------------------------- 1 | ### Calories and Carbohydrates per 100 grams for Common Fruits and Vegetables: 2 | 3 | Please note that the values are approximate and can vary depending on the specific variety and how the food is prepared. 4 | It's always a good idea to check the nutritional labels on packaged foods and consult with a registered dietitian for more precise information. 5 | 6 | - Apples: Approximately 52 calories and 14 grams of carbohydrates. 7 | - Bananas: Approximately 89 calories and 23 grams of carbohydrates. 8 | - Carrots: Approximately 41 calories and 10 grams of carbohydrates. 9 | - Broccoli: Approximately 31 calories and 7 grams of carbohydrates. 10 | - Spinach: Approximately 23 calories and 4 grams of carbohydrates. 11 | - Tomatoes: Approximately 18 calories and 4 grams of carbohydrates. 12 | - Potatoes: Approximately 77 calories and 20 grams of carbohydrates. 13 | - Onions: Approximately 40 calories and 10 grams of carbohydrates. 14 | - Strawberries: Approximately 32 calories and 7 grams of carbohydrates. 15 | - Blueberries: Approximately 57 calories and 14 grams of carbohydrates. 16 | - Grapes: Approximately 69 calories and 18 grams of carbohydrates. 17 | - Peaches: Approximately 39 calories and 9 grams of carbohydrates. 18 | - Bell Peppers: Approximately 31 calories and 6 grams of carbohydrates. 19 | - Lettuce: Approximately 5 calories and 1 gram of carbohydrates. 20 | - Spinach: Approximately 23 calories and 4 grams of carbohydrates. 21 | - Zucchini: Approximately 17 calories and 3 grams of carbohydrates. 22 | - Cucumbers: Approximately 16 calories and 4 grams of carbohydrates. 23 | - Kale: Approximately 49 calories and 9 grams of carbohydrates. 24 | - Garlic: Approximately 149 calories and 33 grams of carbohydrates. 25 | 26 | -------------------------------------------------------------------------------- /data/in_season.txt: -------------------------------------------------------------------------------- 1 | ### Top 50 fresh fruits and vegetables organized by their typical harvest season: 2 | 3 | #### Spring (March - May): 4 | 5 | 1. Strawberries 6 | 2. Asparagus 7 | 3. Peas 8 | 4. Spinach 9 | 5. Radishes 10 | 6. Lettuce 11 | 7. Artichokes 12 | 8. Rhubarb 13 | 9. Broccoli 14 | 10. Carrots 15 | 16 | #### Summer (June - August): 17 | 18 | 11. Tomatoes 19 | 12. Blueberries 20 | 13. Watermelon 21 | 14. Corn 22 | 15. Zucchini 23 | 16. Cucumbers 24 | 17. Bell peppers 25 | 18. Peaches 26 | 19. Cherries 27 | 20. Raspberries 28 | 29 | #### Early Fall (September - October): 30 | 31 | 21. Apples 32 | 22. Grapes 33 | 23. Pears 34 | 24. Plums 35 | 25. Eggplant 36 | 26. Green beans 37 | 27. Cabbage 38 | 28. Cauliflower 39 | 29. Sweet potatoes 40 | 30. Pumpkins 41 | 42 | #### Late Fall (November - December): 43 | 44 | 31. Cranberries 45 | 32. Brussels sprouts 46 | 33. Kale 47 | 34. Butternut squash 48 | 35. Beets 49 | 36. Broccoli rabe 50 | 37. Persimmons 51 | 38. Radicchio 52 | 39. Turnips 53 | 40. Winter squash 54 | 55 | #### Winter (January - February): 56 | 57 | 41. Citrus fruits (oranges, grapefruits, lemons, limes) 58 | 42. Kiwi 59 | 43. Pineapples 60 | 44. Mangoes 61 | 45. Avocados 62 | 46. Bananas 63 | 47. Papayas 64 | 48. Guavas 65 | 49. Fennel 66 | 50. Dates 67 | 68 | Note that the specific availability of these fruits and vegetables can vary based on your location and climate, 69 | so it's a good idea to check with local farmers' markets or grocery stores for the most accurate information on 70 | seasonal produce in your area. 71 | -------------------------------------------------------------------------------- /data/mealplan.txt: -------------------------------------------------------------------------------- 1 | ### Meal Plan 2 | 3 | Here's a healthy dinner meal plan for a week with whole foods and one cheat day included. 4 | Remember to adjust portion sizes and ingredients based on your dietary preferences and caloric needs. 5 | 6 | ### Outline Summary 7 | 1. Day 1: Grilled Chicken Salad 8 | 2. Day 2: Baked Salmon 9 | 3. Day 3: Vegetarian Stir-Fry 10 | 4. Day 4: Mediterranean Chickpea Bowl 11 | 5. Day 5: Beef and Broccoli 12 | 6. Day 6: Roasted Vegetable Pasta7 13 | 7. Day 7 (Cheat Day): Your Favorite Indulgence 14 | 8. Day 8: Grilled Shrimp Tacos 15 | 16 | ### Full Plan 17 | 18 | **Day 1: Grilled Chicken Salad** 19 | - Grilled chicken breast with mixed greens, cherry tomatoes, cucumbers, and a balsamic vinaigrette dressing. 20 | - Side of quinoa or brown rice. 21 | 22 | **Day 2: Baked Salmon** 23 | - Baked salmon with a lemon-dill sauce. 24 | - Steamed broccoli and a side of sweet potato. 25 | 26 | **Day 3: Vegetarian Stir-Fry** 27 | - Tofu or tempeh stir-fried with bell peppers, broccoli, snap peas, and a low-sodium teriyaki sauce. 28 | - Serve over brown rice or cauliflower rice. 29 | 30 | **Day 4: Mediterranean Chickpea Bowl** 31 | - Chickpeas roasted with olive oil, garlic, and spices. 32 | - Serve over a bed of spinach, with diced cucumber, cherry tomatoes, and feta cheese. Drizzle with tahini dressing. 33 | 34 | **Day 5: Beef and Broccoli** 35 | - Lean beef stir-fried with broccoli and a homemade sauce (low-sodium soy sauce, garlic, ginger, and honey). 36 | - Serve with quinoa or whole wheat noodles. 37 | 38 | **Day 6: Roasted Vegetable Pasta** 39 | - Whole wheat pasta with roasted cherry tomatoes, zucchini, bell peppers, and red onion. 40 | - Toss with a light olive oil and herb sauce, and top with grated Parmesan cheese. 41 | 42 | **Day 7 (Cheat Day): Your Favorite Indulgence** 43 | - Enjoy your favorite meal, whether it's pizza, burgers, or something sweet. 44 | - Remember to practice portion control and enjoy it guilt-free! 45 | 46 | **Day 8: Grilled Shrimp Tacos** 47 | - Grilled shrimp with taco seasoning, served in whole wheat tortillas. 48 | - Top with shredded lettuce, diced tomatoes, avocado slices, and a yogurt-based cilantro-lime sauce. 49 | -------------------------------------------------------------------------------- /data/walocal.txt: -------------------------------------------------------------------------------- 1 | ### Washington State Local Produce 2 | 3 | Washington state is known for its rich agricultural production. Here's a list of the types of produce that are commonly available from local farmers in Washington state: 4 | 5 | #### Fruits: 6 | 7 | 1. Apples (Washington is famous for its apple orchards) 8 | 2. Cherries (particularly in the Yakima Valley) 9 | 3. Pears 10 | 4. Peaches 11 | 5. Plums 12 | 6. Blueberries 13 | 7. Raspberries 14 | 8. Strawberries 15 | 9. Blackberries 16 | 10. Grapes (used for wine production as well) 17 | 11. Apricots 18 | 12. Cranberries (especially in the Long Beach Peninsula) 19 | 13. Kiwi 20 | 14. Huckleberries (in certain regions) 21 | 15. Nectarines 22 | 23 | #### Vegetables: 24 | 25 | 16. Potatoes (including famous Washington russet potatoes) 26 | 17. Onions 27 | 18. Carrots 28 | 19. Sweet corn 29 | 20. Asparagus 30 | 21. Green beans 31 | 22. Cabbage 32 | 23. Broccoli 33 | 24. Cauliflower 34 | 25. Peppers (bell peppers and hot peppers) 35 | 26. Tomatoes 36 | 27. Cucumbers 37 | 28. Lettuce and salad greens 38 | 29. Spinach 39 | 30. Zucchini and summer squash 40 | 31. Pumpkins (popular for Halloween and pies) 41 | 32. Winter squash (e.g., butternut, acorn) 42 | 33. Brussels sprouts 43 | 34. Kale 44 | 35. Garlic 45 | 36. Leeks 46 | 37. Rhubarb 47 | 38. Beets 48 | 39. Swiss chard 49 | 40. Peas 50 | 51 | #### Berries and Other Specialty Crops: 52 | 53 | 41. Marionberries (a type of blackberry) 54 | 42. Boysenberries 55 | 43. Loganberries 56 | 44. Gooseberries 57 | 45. Tart cherries (used for pies and jams) 58 | 46. Red currants 59 | 47. Raspberries for wine production 60 | 48. Lavender (used for culinary and cosmetic purposes) 61 | 49. Hazelnuts (filberts) 62 | 50. Walnuts 63 | 64 | #### Herbs: 65 | 66 | 51. Mint 67 | 52. Basil 68 | 53. Rosemary 69 | 54. Thyme 70 | 55. Oregano 71 | 56. Cilantro 72 | 57. Parsley 73 | 58. Sage 74 | 59. Dill 75 | 76 | Washington state's diverse climate and topography allow for the cultivation of a wide variety of produce throughout the year. Depending on the region within the state, you may find certain crops more readily available during different seasons. Be sure to visit local farmers' markets and support your local farmers to enjoy the freshest, seasonal produce in Washington. 77 | -------------------------------------------------------------------------------- /ensemble.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from langchain_community.retrievers import BM25Retriever 4 | from langchain.retrievers import EnsembleRetriever 5 | from langchain_core.output_parsers import StrOutputParser 6 | 7 | from basic_chain import get_model 8 | from rag_chain import make_rag_chain 9 | from remote_loader import load_web_page 10 | from splitter import split_documents 11 | from vector_store import create_vector_db 12 | from dotenv import load_dotenv 13 | 14 | 15 | def ensemble_retriever_from_docs(docs, embeddings=None): 16 | texts = split_documents(docs) 17 | vs = create_vector_db(texts, embeddings) 18 | vs_retriever = vs.as_retriever() 19 | 20 | bm25_retriever = BM25Retriever.from_texts([t.page_content for t in texts]) 21 | 22 | ensemble_retriever = EnsembleRetriever( 23 | retrievers=[bm25_retriever, vs_retriever], 24 | weights=[0.5, 0.5]) 25 | 26 | return ensemble_retriever 27 | 28 | 29 | def main(): 30 | load_dotenv() 31 | 32 | problems_of_philosophy_by_russell = "https://www.gutenberg.org/ebooks/5827.html.images" 33 | docs = load_web_page(problems_of_philosophy_by_russell) 34 | ensemble_retriever = ensemble_retriever_from_docs(docs) 35 | model = get_model("ChatGPT") 36 | chain = make_rag_chain(model, ensemble_retriever) | StrOutputParser() 37 | 38 | result = chain.invoke("What are the key problems of philosophy according to Russell?") 39 | print(result) 40 | 41 | 42 | if __name__ == "__main__": 43 | # this is to quite parallel tokenizers warning. 44 | os.environ["TOKENIZERS_PARALLELISM"] = "false" 45 | main() 46 | 47 | -------------------------------------------------------------------------------- /examples/grocery.md: -------------------------------------------------------------------------------- 1 | # Grocery List 2 | 3 | - Eggs 4 | - Milk 5 | - Bread 6 | - Tomatoes 7 | - Bananas -------------------------------------------------------------------------------- /examples/healthy_meal_10_tips.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBash/langchain-RAG/757823b804a28e3673303d13c16ace71364b6bf3/examples/healthy_meal_10_tips.pdf -------------------------------------------------------------------------------- /examples/mal_boole.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueBash/langchain-RAG/757823b804a28e3673303d13c16ace71364b6bf3/examples/mal_boole.pdf -------------------------------------------------------------------------------- /examples/nutrients_csvfile.csv: -------------------------------------------------------------------------------- 1 | Food,Measure,Grams,Calories,Protein,Fat,Sat.Fat,Fiber,Carbs,Category 2 | Cows' milk,1 qt.,976,660,32,40,36,0,48,Dairy products 3 | Milk skim,1 qt.,984,360,36,t,t,0,52,Dairy products 4 | Buttermilk,1 cup,246,127,9,5,4,0,13,Dairy products 5 | "Evaporated, undiluted",1 cup,252,345,16,20,18,0,24,Dairy products 6 | Fortified milk,6 cups,"1,419","1,373",89,42,23,1.4,119,Dairy products 7 | Powdered milk,1 cup,103,515,27,28,24,0,39,Dairy products 8 | "skim, instant",1 1/3 cups,85,290,30,t,t,0,42,Dairy products 9 | "skim, non-instant",2/3 cup,85,290,30,t,t,1,42,Dairy products 10 | Goats' milk,1 cup,244,165,8,10,8,0,11,Dairy products 11 | (1/2 cup ice cream),2 cups,540,690,24,24,22,0,70,Dairy products 12 | Cocoa,1 cup,252,235,8,11,10,0,26,Dairy products 13 | skim. milk,1 cup,250,128,18,4,3,1,13,Dairy products 14 | (cornstarch),1 cup,248,275,9,10,9,0,40,Dairy products 15 | Custard,1 cup,248,285,13,14,11,0,28,Dairy products 16 | Ice cream,1 cup,188,300,6,18,16,0,29,Dairy products 17 | Ice milk,1 cup,190,275,9,10,9,0,32,Dairy products 18 | Cream or half-and-half,1/2 cup,120,170,4,15,13,0,5,Dairy products 19 | or whipping,1/2 cup,119,430,2,44,27,1,3,Dairy products 20 | Cheese,1 cup,225,240,30,11,10,0,6,Dairy products 21 | uncreamed,1 cup,225,195,38,t,t,0,6,Dairy products 22 | Cheddar,1-in. cube,17,70,4,6,5,0,t,Dairy products 23 | "Cheddar, grated cup",1/2 cup,56,226,14,19,17,0,1,Dairy products 24 | Cream cheese,1 oz.,28,105,2,11,10,0,1,Dairy products 25 | Processed cheese,1 oz.,28,105,7,9,8,0,t,Dairy products 26 | Roquefort type,1 oz.,28,105,6,9,8,0,t,Dairy products 27 | Swiss,1 oz.,28,105,7,8,7,0,t,Dairy products 28 | Eggs raw,2,100,150,12,12,10,0,t,Dairy products 29 | Eggs Scrambled or fried,2,128,220,13,16,14,0,1,Dairy products 30 | Yolks,2,34,120,6,10,8,0,t,"Fats, Oils, Shortenings" 31 | Butter,1T.,14,100,t,11,10,0,t,"Fats, Oils, Shortenings" 32 | Butter,1/2 cup,112,113,114,115,116,117,118,"Fats, Oils, Shortenings" 33 | Butter,1/4 lb.,112,113,114,115,116,117,118,"Fats, Oils, Shortenings" 34 | Hydrogenated cooking fat,1/2 cup,100,665,0,100,88,0,0,"Fats, Oils, Shortenings" 35 | Lard,1/2 cup,110,992,0,110,92,0,0,"Fats, Oils, Shortenings" 36 | Margarine,1/2 cup,112,806,t,91,76,0,t,"Fats, Oils, Shortenings" 37 | "Margarine, 2 pat or",1 T.,14,100,t,11,9,0,t,"Fats, Oils, Shortenings" 38 | Mayonnaise,1 T.,15,110,t,12,5,0,t,"Fats, Oils, Shortenings" 39 | Corn oil,1 T.,14,125,0,14,5,0,0,"Fats, Oils, Shortenings" 40 | Olive oil,1T.,14,125,0,14,3,0,0,"Fats, Oils, Shortenings" 41 | Safflower seed oil,1 T.,14,125,0,14,3,0,0,"Fats, Oils, Shortenings" 42 | French dressing,1 T.,15,60,t,6,2,0,2,"Fats, Oils, Shortenings" 43 | Thousand Island sauce,1 T.,15,75,t,8,3,0,1,"Fats, Oils, Shortenings" 44 | Salt pork,2 oz.,60,470,3,55,,0,0,"Meat, Poultry" 45 | Bacon,2 slices,16,95,4,8,7,0,1,"Meat, Poultry" 46 | Beef,3 oz.,85,245,23,16,15,0,0,"Meat, Poultry" 47 | Hamburger,3 oz.,85,245,21,17,15,0,0,"Meat, Poultry" 48 | Ground lean,3 oz.,85,185,24,10,9,0,0,"Meat, Poultry" 49 | Roast beef,3 oz.,85,390,16,36,35,0,0,"Meat, Poultry" 50 | Steak,3 oz.,85,330,20,27,25,0,0,"Meat, Poultry" 51 | "Steak, lean, as round",3 oz.,85,220,24,12,11,0,0,"Meat, Poultry" 52 | Corned beef,3 oz.,85,185,22,10,9,0,0,"Meat, Poultry" 53 | Corned beef hash canned,3 oz.,85,120,12,8,7,t,6,"Meat, Poultry" 54 | Corned beef hash Dried,2 oz.,56,115,19,4,4,0,0,"Meat, Poultry" 55 | Pot-pie,1 pie,227,480,18,28,25,t,32,"Meat, Poultry" 56 | Corned beef hash Stew,1 cup,235,185,15,10,9,t,15,"Meat, Poultry" 57 | chicken,3 oz.,85,185,23,9,7,0,0,"Meat, Poultry" 58 | "Fried, breast or leg and thigh chicken",3 oz.,85,245,25,15,11,0,0,"Meat, Poultry" 59 | Roasted chicken,3 1/2 oz.,100,290,25,20,16,0,0,"Meat, Poultry" 60 | "Chicken livers, fried",3 med.,100,140,22,14,12,0,2.30,"Meat, Poultry" 61 | "Duck, domestic",3 1/2 oz.,100,370,16,28,0,0,0,"Meat, Poultry" 62 | "Lamb, chop, broiled",4 oz.,115,480,24,35,33,0,0,"Meat, Poultry" 63 | Leg roasted,3 oz.,86,314,20,14,14,0,0,"Meat, Poultry" 64 | "Shoulder, braised",3 oz.,85,285,18,23,21,0,0,"Meat, Poultry" 65 | "Pork, chop, 1 thick",3 1/2 oz.,100,260,16,21,18,0,0,"Meat, Poultry" 66 | Ham pan-broiled,3 oz.,85,290,16,22,19,0,0,"Meat, Poultry" 67 | "Ham, as ",2 oz.,57,170,13,13,11,0,0,"Meat, Poultry" 68 | "Ham, canned, spiced",2 oz.,57,165,8,14,12,0,1,"Meat, Poultry" 69 | Pork roast,3 oz.,85,310,21,24,21,0,0,"Meat, Poultry" 70 | Pork sausage,3 1/2 oz.,100,475,18,44,40,0,0,"Meat, Poultry" 71 | Turkey,3 1/2 oz.,100,265,27,15,0,0,0,"Meat, Poultry" 72 | Veal,3 oz.,85,185,23,9,8,0,0,"Meat, Poultry" 73 | Roast,3 oz.,85,305,13,14,13,0,0,"Meat, Poultry" 74 | Clams,3 oz.,85,87,12,1,0,0,2,"Fish, Seafood" 75 | Cod,3 1/2 oz.,100,170,28,5,0,0,0,"Fish, Seafood" 76 | Crab meat,3 oz.,85,90,14,2,0,0,1,"Fish, Seafood" 77 | Fish sticks fried,5,112,200,19,10,5,0,8,"Fish, Seafood" 78 | Flounder,3 1/2 oz.,100,200,30,8,0,0,0,"Fish, Seafood" 79 | Haddock,3 oz.,85,135,16,5,4,0,6,"Fish, Seafood" 80 | Halibut,3 1/2 oz.,100,182,26,8,0,0,0,"Fish, Seafood" 81 | Herring,1 small,100,211,22,13,0,0,0,"Fish, Seafood" 82 | Lobster,aver.,100,92,18,1,0,0,t,"Fish, Seafood" 83 | Mackerel,3 oz.,85,155,18,9,0,a,0,"Fish, Seafood" 84 | Oysters,6-8 med.,230,231,232,233,234,235,236,"Fish, Seafood" 85 | Oyster stew,1 cup,85,125,19,6,1,0,0,"Fish, Seafood" 86 | Salmon,3 oz.,85,120,17,5,1,0,0,"Fish, Seafood" 87 | Sardines,3 oz.,85,180,22,9,4,0,0,"Fish, Seafood" 88 | Scallops,3 1/2 oz.,100,104,18,8,0,0,10,"Fish, Seafood" 89 | Shad,3 oz.,85,170,20,10,0,0,0,"Fish, Seafood" 90 | Shrimp,3 oz.,85,110,23,1,0,0,0,"Fish, Seafood" 91 | Swordfish,1 steak,100,180,27,6,0,0,0,"Fish, Seafood" 92 | Tuna,3 oz.,85,170,25,7,3,0,0,"Fish, Seafood" 93 | Artichoke,1 large,100,8-44,2,t,t,2,10,Vegetables A-E 94 | Asparagus,6 spears,96,18,1,t,t,0.5,3,Vegetables A-E 95 | Beans,1 cup,125,25,1,t,t,0.8,6,Vegetables A-E 96 | Lima,1 cup,160,140,8,t,t,3.0,24,Vegetables A-E 97 | "Lima, dry, cooked",1 cup,192,260,16,t,t,2,48,Vegetables A-E 98 | "Navy, baked with pork",3/4 cup,200,250,11,6,6,2,37,Vegetables A-E 99 | Red kidney,1 cup,260,230,15,1,0,2.5,42,Vegetables A-E 100 | Bean sprouts,1 cup,50,17,1,t,0,0.3,3,Vegetables A-E 101 | Beet greens,1 cup,100,27,2,t,0,1.4,6,Vegetables A-E 102 | Beetroots,1 cup,165,1,12,0,,t,0.80,Vegetables A-E 103 | Broccoli,1 cup,150,45,5,t,0,1.9,8,Vegetables A-E 104 | Brussels sprouts,1 cup,130,60,6,t,0,1.7,12,Vegetables A-E 105 | Sauerkraut,1 cup,150,32,1,t,0,1.2,7,Vegetables A-E 106 | Steamed cabbage,1 cup,170,40,2,t,0,1.3,9,Vegetables A-E 107 | Carrots,1 cup,150,45,1,t,0,0.9,10,Vegetables A-E 108 | "Raw, grated",1 cup,110,45,1,t,0,1.2,10,Vegetables A-E 109 | "Strips, from raw",1 mad.,50,20,t,t,0,0.5,5,Vegetables A-E 110 | Cauliflower,1 cup,120,30,3,t,0,1,6,Vegetables A-E 111 | Celery,1 cup,100,20,1,t,0,1,4,Vegetables A-E 112 | Stalk raw,1 large,40,5,1,t,0,0.3,1,Vegetables A-E 113 | Chard steamed,1 cup,150,30,2,t,0,1.4,7,Vegetables A-E 114 | Collards,1 cup,150,51,5,t,0,2,8,Vegetables A-E 115 | Corn,1 ear,100,92,3,1,t,0.8,21,Vegetables A-E 116 | cooked or canned,1 cup,200,170,5,t,0,1.6,41,Vegetables A-E 117 | Cucumbers,8,50,6,t,0,0,0.2,1,Vegetables A-E 118 | Dandelion greens,1 cup,180,80,5,1,0,3.2,16,Vegetables A-E 119 | Eggplant,1 cup,180,30,2,t,0,1.0,9,Vegetables A-E 120 | Endive,2 oz.,57,10,1,t,0,0.6,2,Vegetables A-E 121 | Kale,1 cup,110,45,4,1,0,0.9,8,Vegetables F-P 122 | Kohlrabi,1 cup,140,40,2,t,0,1.5,9,Vegetables F-P 123 | "Lambs quarters, steamed",1 cup,150,48,5,t,0,3.2,7,Vegetables F-P 124 | Lentils,1 cup,200,212,15,t,0,2.4,38,Vegetables F-P 125 | Lettuce,1/4 head,100,14,1,t,0,0.5,2,Vegetables F-P 126 | Iceberg,1/4 head,100,13,t,t,0,0.5,3,Vegetables F-P 127 | Mushrooms canned,4,120,12,2,t,0,t,4,Vegetables F-P 128 | Mustard greens,1,140,30,3,t,0,1.2,6,Vegetables F-P 129 | Okra,1 1/3 cups,100,32,1,t,0,1,7,Vegetables F-P 130 | Onions,1,210,80,2,t,0,1.6,18,Vegetables F-P 131 | "Raw, green",6 small,50,22,t,t,0,1,5,Vegetables F-P 132 | Parsley,2 T.,50,2,t,t,0,t,t,Vegetables F-P 133 | Parsnips,1 cup,155,95,2,1,0,3,22,Vegetables F-P 134 | Peas,1 cup,100,66,3,t,0,0.1,13,Vegetables F-P 135 | "Fresh, steamed peas",1 cup,100,70,5,t,0,2.2,12,Vegetables R-Z 136 | Frozen peas,1 cup,100,,5,t,0,1.8,12,Vegetables R-Z 137 | Split cooked peas,4 cups,100,115,8,t,0,0.4,21,Vegetables R-Z 138 | heated peas,1 cup,100,53,3,t,0,1,10,Vegetables R-Z 139 | Peppers canned,1 pod,38,10,t,t,0,t,2,Vegetables R-Z 140 | "Peppers Raw, green, sweet",1 large,100,25,1,t,0,1.4,6,Vegetables R-Z 141 | Peppers with beef and crumbs,1 med.,150,255,19,9,8,1,24,Vegetables R-Z 142 | "Potatoes, baked",1 med.,100,100,2,t,0,0.5,22,Vegetables R-Z 143 | French-fried,10 pieces,60,155,-1,7,3,0.4,20,Vegetables R-Z 144 | Potatoes Mashed with milk and butter,1 cup,200,230,4,12,11,0.7,28,Vegetables R-Z 145 | "Potatoes, pan-tried",3/4 cup,100,268,4,14,6,0.40,33,Vegetables R-Z 146 | Scalloped with cheese potatoes,3/4 cup,100,145,6,8,7,0.40,14,Vegetables R-Z 147 | Steamed potatoes before peeling,1 med.,100,80,2,t,0,0.40,19,Vegetables R-Z 148 | Potato chips,10,20,110,1,7,4,t,10,Vegetables R-Z 149 | Radishes,5 small,50,10,t,0,0,0.3,2,Vegetables R-Z 150 | Rutabagas,4 cups,100,32,t,0,0,1.4,8,Vegetables R-Z 151 | Soybeans,1 cup,200,260,22,11,0,3.2,20,Vegetables R-Z 152 | Spinach,1 cup,100,26,3,t,0,1,3,Vegetables R-Z 153 | Squash,1 cup,210,35,1,t,0,0.6,8,Vegetables R-Z 154 | "Winter, mashed",1 cup,200,95,4,t,0,2.6,23,Vegetables R-Z 155 | Sweet potatoes,1 med.,110,155,2,1,0,1,36,Vegetables R-Z 156 | Candied,1 med.,175,235,2,6,5,1.5,80,Vegetables R-Z 157 | Tomatoes,1 cup,240,50,2,t,0,1,9,Vegetables R-Z 158 | "Raw, 2 by 2 1/2",1 med.,150,30,1,t,0,0.6,6,Vegetables R-Z 159 | Tomato juice,1 cup,240,50,2,t,0,0.6,10,Vegetables R-Z 160 | Tomato catsup,1 T.,17,15,t,t,0,t,4,Vegetables R-Z 161 | Turnip greens,1 cup,145,45,4,1,0,1.8,8,Vegetables R-Z 162 | "Turnips, steamed",1 cup,155,40,1,t,0,1.8,9,Vegetables R-Z 163 | "Watercress stems, raw",1 cup,50,9,1,t,0,0.3,1,Fruits A-F 164 | Apple juice canned,1 cup,250,125,t,0,0,0,34,Fruits A-F 165 | Apple vinegar,1/3 cup,100,14,t,0,0,0,3,Fruits A-F 166 | "Apples, raw",1 med,130,70,t,t,0,1,18,Fruits A-F 167 | Stewed or canned,1 cup,240,100,t,t,0,2,26,Fruits A-F 168 | Apricots,1 cup,250,220,2,t,0,1,57,Fruits A-F 169 | "Dried, uncooked",1/2 cup,75,220,4,t,0,1,50,Fruits A-F 170 | Fresh,3 med.,114,55,1,t,0,0.70,14,Fruits A-F 171 | "Nectar, or juice",1 cup,250,140,1,t,0,2,36,Fruits A-F 172 | Avocado,1/2 large,108,185,2,18,12,1.80,6,Fruits A-F 173 | Banana,1 med.,150,85,1,t,0,0.9,23,Fruits A-F 174 | Blackberries,1 cup,144,85,2,1,0,6.60,19,Fruits A-F 175 | Blueberries,1 cup,250,245,1,t,0,2,65,Fruits A-F 176 | Cantaloupe,1/2 med.,380,40,1,t,0,2.20,9,Fruits A-F 177 | Cherries,1 cup,257,100,2,1,0,2,26,Fruits A-F 178 | "Fresh, raw",1 cup,114,65,1,t,0,0.8,15,Fruits A-F 179 | Cranberry sauce sweetened,1 cup,277,530,t,t,0,1.2,142,Fruits A-F 180 | Dates,1 cup,178,505,4,t,0,3.6,134,Fruits A-F 181 | Figs,2,42,120,2,t,0,1.9,30,Fruits A-F 182 | "Fresh, raw figs",3 med.,114,90,2,t,0,1,22,Fruits A-F 183 | figs Canned with syrup ,3,115,130,1,t,0,1,32,Fruits A-F 184 | "Fruit cocktail, canned",1 cup,256,195,1,t,0,0.5,50,Fruits A-F 185 | Grapefruit sections,1 cup,250,170,1,t,0,0.5,44,Fruits G-P 186 | "Grapefruit, fresh, 5"" diameter",1/2,285,50,1,t,t,1,14,Fruits G-P 187 | Grapefruit juice,1 cup,250,100,1,t,0,1,24,Fruits G-P 188 | Grapes,1 cup,153,70,1,t,0,0.8,16,Fruits G-P 189 | "European, as Muscat, Tokay",1 cup,160,100,1,t,0,0.7,26,Fruits G-P 190 | Grape juice,1 cup,250,160,1,t,0,t,42,Fruits G-P 191 | Lemon juice,1/2 cup,125,30,t,t,0,t,10,Fruits G-P 192 | Lemonade concentratefrozen,6-oz. can,220,430,t,t,0,t,112,Fruits G-P 193 | Limeade concentrate frozen,6-oz. can,218,405,t,t,0,t,108,Fruits G-P 194 | Olives large,10,65,72,1,10,9,0.8,3,Fruits G-P 195 | OlivesRipe,10,65,105,1,13,12,1,1,Fruits G-P 196 | "Oranges 3"" diameter",1 med.,180,60,2,t,t,1,16,Fruits G-P 197 | Orange juice,8 oz. or,250,112,2,t,0,0.2,25,Fruits G-P 198 | Frozen ,6-oz. can,210,330,2,t,t,0.4,78,Fruits G-P 199 | Papaya,1/2 med.,200,75,1,t,0,1.8,18,Fruits G-P 200 | Peaches,1 cup,257,200,1,t,0,1,52,Fruits G-P 201 | "Fresh, raw",1 med.,114,35,1,t,0,0.6,10,Fruits G-P 202 | Pears,1 cup,255,195,1,t,0,2,50,Fruits G-P 203 | "Raw, 3 by 2V",1 med.,182,100,1,1,0,2,25,Fruits G-P 204 | Persimmons,1 med.,125,75,1,t,0,2,20,Fruits G-P 205 | Pineapple,1 large slice,122,95,t,t,0,0.4,26,Fruits G-P 206 | Pineapple Crushed,1 cup,260,205,1,t,0,0.7,55,Fruits G-P 207 | "Raw, diced",1 cup,140,75,1,t',0,0.6,19,Fruits G-P 208 | Pineapple juice,1 cup,250,120,1,t,0,0.2,32,Fruits G-P 209 | Plums,1 cup,256,185,1,t,0,0.7,50,Fruits G-P 210 | "Raw, 2"" diameter",1,60,30,t,t,0,0.2,7,Fruits G-P 211 | Prunes,1 cup,270,300,3,1,0,0.8,81,Fruits G-P 212 | Prune juice,1 cup,240,170,1,t,0,0.7,45,Fruits G-P 213 | Raisins,1/2 cup,88,230,2,t,0,0.7,82,Fruits R-Z 214 | Raspberries,1/2 cup,100,100,t,t,0,2,25,Fruits R-Z 215 | "Raw, red",3/4 cup,100,57,t,t,0,5,14,Fruits R-Z 216 | Rhubarb sweetened,1 cup,270,385,1,t,0,1.9,98,Fruits R-Z 217 | Strawberries,1 cup,227,242,1,t,0,1.3,60,Fruits R-Z 218 | Raw,1 cup,149,54,t,t,0,1.9,12,Fruits R-Z 219 | Tangerines,I med.,114,40,1,t,0,1,10,Fruits R-Z 220 | Watermelon,1 wedge,925,120,2,1,0,3.6,29,Fruits R-Z 221 | Biscuits,1,38,130,3,4,3,t,18,"Breads, cereals, fastfood,grains" 222 | Bran flakes,1 cup,25,117,3,t,0,0.10,32,"Breads, cereals, fastfood,grains" 223 | "Bread, cracked wheat",1 slice,23,60,2,1,1,0.10,12,"Breads, cereals, fastfood,grains" 224 | Rye,1 slice,23,55,2,1,1,0.10,12,"Breads, cereals, fastfood,grains" 225 | "White, 20 slices, or",1-lb. loaf,454,"1,225",39,15,12,9.00,229,"Breads, cereals, fastfood,grains" 226 | Whole-wheat,1-lb. loaf,454,"1,100",48,14,10,67.50,216,"Breads, cereals, fastfood,grains" 227 | Whole-wheat,1 slice,23,55,2,1,0,0.31,11,"Breads, cereals, fastfood,grains" 228 | Corn bread ground meal,1 serving,50,100,3,4,2,0.30,15,"Breads, cereals, fastfood,grains" 229 | Cornflakes,1 cup,25,110,2,t,0,0.1,25,"Breads, cereals, fastfood,grains" 230 | Corn grits cooked,1 cup,242,120,8,t,0,0.2,27,"Breads, cereals, fastfood,grains" 231 | Corn meal,1 cup,118,360,9,4,2,1.6,74,"Breads, cereals, fastfood,grains" 232 | Crackers,2 med.,14,55,1,1,0,t,10,"Breads, cereals, fastfood,grains" 233 | "Soda, 2 1/2 square",2,11,45,1,1,0,t,8,"Breads, cereals, fastfood,grains" 234 | Farina,1 cup,238,105,3,t,0,8,22,"Breads, cereals, fastfood,grains" 235 | Flour,1 cup,110,460,39,22,0,2.9,33,"Breads, cereals, fastfood,grains" 236 | Wheat (all purpose),1 cup,110,400,12,1,0,0.3,84,"Breads, cereals, fastfood,grains" 237 | Wheat (whole),1 cup,120,390,13,2,0,2.8,79,"Breads, cereals, fastfood,grains" 238 | Macaroni,1 cup,140,155,5,1,0,0.1,32,"Breads, cereals, fastfood,grains" 239 | Baked with cheese,1 cup,220,475,18,25,24,t,44,"Breads, cereals, fastfood,grains" 240 | Muffins,1,48,135,4,5,4,t,19,"Breads, cereals, fastfood,grains" 241 | Noodles,1 cup,160,200,7,2,2,0.1,37,"Breads, cereals, fastfood,grains" 242 | Oatmeal,1 cup,236,150,5,3,2,4.6,26,"Breads, cereals, fastfood,grains" 243 | "Pancakes 4"" diam.",4,108,250,7,9,0,0.1,28,"Breads, cereals, fastfood,grains" 244 | "Wheat, pancakes 4"" diam.",4,108,250,7,9,0,0.1,28,"Breads, cereals, fastfood,grains" 245 | "Pizza 14"" diam.",1 section,75,180,8,6,5,t,23,"Breads, cereals, fastfood,grains" 246 | Popcorn salted,2 cups,28,152,3,7,2,0.5,20,"Breads, cereals, fastfood,grains" 247 | Puffed rice,1 cup,14,55,t,t,0,t,12,"Breads, cereals, fastfood,grains" 248 | Puffed wheat presweetened,1 cup,28,105,1,t,0,0.6,26,"Breads, cereals, fastfood,grains" 249 | Rice,1 cup,208,748,15,3,0,1.2,154,"Breads, cereals, fastfood,grains" 250 | Converted,1 cup,187,677,14,t,0,0.4,142,"Breads, cereals, fastfood,grains" 251 | White,1 cup,191,692,14,t,0,0.3,150,"Breads, cereals, fastfood,grains" 252 | Rice flakes,1 cup,30,115,2,t,0,0.1,26,"Breads, cereals, fastfood,grains" 253 | Rice polish,1/2 cup,50,132,6,6,0,1.2,28,"Breads, cereals, fastfood,grains" 254 | Rolls,1 large,50,411,3,12,11,0.1,23,"Breads, cereals, fastfood,grains" 255 | of refined flour,1,38,115,3,2,2,t,20,"Breads, cereals, fastfood,grains" 256 | whole-wheat,1,40,102,4,1,0,0.1,20,"Breads, cereals, fastfood,grains" 257 | Spaghetti with meat sauce,1 cup,250,285,13,10,6,0.50,35,"Breads, cereals, fastfood,grains" 258 | with tomatoes and cheese,1 cup,250,210,6,5,3,0.50,36,"Breads, cereals, fastfood,grains" 259 | Spanish rice,1 cup,250,217,4,4,0,1.20,40,"Breads, cereals, fastfood,grains" 260 | Shredded wheat biscuit,1,28,100,3,1,0,0.70,23,"Breads, cereals, fastfood,grains" 261 | Waffles,1,75,240,8,9,1,0.10,30,"Breads, cereals, fastfood,grains" 262 | Wheat germ,1 cup,68,245,17,7,3,2.50,34,"Breads, cereals, fastfood,grains" 263 | Wheat-germ cereal toasted,1 cup,65,260,20,7,3,2.50,36,"Breads, cereals, fastfood,grains" 264 | Wheat meal cereal unrefined,3/4 cup,30,103,4,1,0,0.70,25,"Breads, cereals, fastfood,grains" 265 | "Wheat, cooked",3/4 cup,200,275,12,1,0,4.40,35,"Breads, cereals, fastfood,grains" 266 | Bean soups,1 cup,250,190,8,5,4,0.60,30,Soups 267 | Beef soup,1 cup,250,100,6,4,4,0.50,11,Soups 268 | Bouillon,1 cup,240,24,5,0,0,0,0,Soups 269 | chicken soup,1 cup,250,75,4,2,2,0,10,Soups 270 | Clam chowder,1 cup,255,85,5,2,8,0.50,12,Soups 271 | Cream soups,1 cup,255,200,7,12,11,1.20,18,Soups 272 | Noodle,1 cup,250,115,6,4,3,0.20,13,Soups 273 | Split-pea soup,1 cup,250,147,8,3,3,0.50,25,Soups 274 | Tomato soup,1 cup,245,175,6,7,6,0.50,22,Soups 275 | Vegetable,1 cup,250,80,4,2,2,0,14,Soups 276 | Apple betty,1 serving,100,150,1,4,0,0.5,29,"Desserts, sweets" 277 | Bread pudding,3/4 cup,200,374,11,12,11,0.20,56,"Desserts, sweets" 278 | Cakes,1 slice,40,110,3,t,0,0,23,"Desserts, sweets" 279 | Chocolate fudge,1 slice,120,420,5,14,12,0.3,70,"Desserts, sweets" 280 | Cupcake,1,50,160,3,3,2,t,31,"Desserts, sweets" 281 | Fruit cake,1 slice,30,105,2,4,3,0.2,17,"Desserts, sweets" 282 | Gingerbread,1 slice,55,180,2,7,6,t,28,"Desserts, sweets" 283 | "Plain, with no icing",1 slice,55,180,4,5,4,t,31,"Desserts, sweets" 284 | Sponge cake,1 slice,40,115,3,2,2,0,22,"Desserts, sweets" 285 | Candy,5,25,104,t,3,3,0,19,"Desserts, sweets" 286 | Chocolate creams,2,30,130,t,4,4,0,24,"Desserts, sweets" 287 | Fudge,2 pieces,90,370,t,12,11,0.1,80,"Desserts, sweets" 288 | Hard candies,1 oz.,28,90,t,0,0,0,28,"Desserts, sweets" 289 | Marshmallows,5,30,98,1,0,0,0,23,"Desserts, sweets" 290 | Milk chocolate,2-oz. bar,56,290,2,6,6,0.2,44,"Desserts, sweets" 291 | Chocolate syrup,2 T.,40,80,t,t,t,0,22,"Desserts, sweets" 292 | Doughnuts,1,33,135,2,7,4,t,17,"Desserts, sweets" 293 | "Gelatin, made with water",1 cup,239,155,4,t,t,0,36,"Desserts, sweets" 294 | Honey,2 T.,42,120,t,0,0,0,30,"Jams, Jellies" 295 | Ice cream,2 cups,300,250,0,0,12,10,0,"Desserts, sweets" 296 | Ices,1 cup,150,117,0,0,0,0,48,"Desserts, sweets" 297 | preserves,1 T.,20,55,0,0,0,t,14,"Jams, Jellies" 298 | Jellies,1 T.,20,50,0,0,0,0,13,"Jams, Jellies" 299 | Molasses,1 T.,20,45,0,0,0,8,11,"Jams, Jellies" 300 | Cane Syrup,1 T.,20,50,0,0,0,0,13,"Jams, Jellies" 301 | "9"" diam. pie",1 slice,135,330,3,13,11,0.1,53,"Desserts, sweets" 302 | Cherry Pie,1 slice,135,340,3,13,11,0.1,55,"Desserts, sweets" 303 | Custard,1 slice,130,265,7,11,10,0,34,"Desserts, sweets" 304 | Lemon meringue,1 slice,120,300,4,12,10,0.1,45,"Desserts, sweets" 305 | Mince,1 slice,135,340,3,9,8,0.70,62,"Desserts, sweets" 306 | Pumpkin Pie,1 slice,130,265,5,12,11,8,34,"Desserts, sweets" 307 | Puddings Sugar,1 cup,200,770,0,0,0,0,199,"Desserts, sweets" 308 | 3 teaspoons sugar,1 T.,12,50,0,0,0,0,12,"Desserts, sweets" 309 | "Brown, firm-packed, dark sugar",1 cup,220,815,0,t,0,0,210,"Jams, Jellies" 310 | Syrup,2 T.,40,100,0,0,0,0,25,"Jams, Jellies" 311 | table blends sugar,2 T.,40,110,0,0,0,0,29,"Jams, Jellies" 312 | Tapioca cream pudding,1 cup,250,335,10,10,9,0,42,"Desserts, sweets" 313 | Almonds,1/2 cup,70,425,13,38,28,1.8,13,Seeds and Nuts 314 | roasted and salted,1/2 cup,70,439,13,40,31,1.8,13,Seeds and Nuts 315 | Brazil nuts,1/2 cup,70,457,10,47,31,2,7,Seeds and Nuts 316 | Cashews,1/2 cup,70,392,12,32,28,0.9,20,Seeds and Nuts 317 | coconut sweetened,1/2 cup,50,274,1,20,19,2,26,Seeds and Nuts 318 | Peanut butter,1/3 cup,50,300,12,25,17,0.9,9,Seeds and Nuts 319 | "Peanut butter, natural",1/3 cup,50,284,13,24,10,0.9,8,Seeds and Nuts 320 | Peanuts,1/3 cup,50,290,13,25,16,1.2,9,Seeds and Nuts 321 | Pecans,1/2 cup,52,343,5,35,25,1.1,7,Seeds and Nuts 322 | Sesame seeds,1/2 cup,50,280,9,24,13,3.1,10,Seeds and Nuts 323 | Sunflower seeds,1/2 cup,50,280,12,26,7,1.9,10,Seeds and Nuts 324 | Walnuts,1/2 cup,50,325,7,32,7,1,8,Seeds and Nuts 325 | Beer,2 cups,480,228,t,0,0,0,8,"Drinks,Alcohol, Beverages" 326 | Gin,1 oz.,28,70,0,0,0,0,t,"Drinks,Alcohol, Beverages" 327 | Wines,1/2 cup,120,164,t,0,0,0,9,"Drinks,Alcohol, Beverages" 328 | Table (12.2% alcohol),1/2 cup,120,100,t,0,0,0,5,"Drinks,Alcohol, Beverages" 329 | Carbonated drinks Artificially sweetened,12 oz.,346,0,0,0,0,0,0,"Drinks,Alcohol, Beverages" 330 | Club soda,12 oz.,346,0,0,0,0,0,0,"Drinks,Alcohol, Beverages" 331 | Cola drinks,12 oz.,346,137,0,0,0,0,38,"Drinks,Alcohol, Beverages" 332 | Fruit-flavored soda,12 oz.,346,161,0,0,0,0,42,"Drinks,Alcohol, Beverages" 333 | Ginger ale,12 oz.,346,105,0,0,0,0,28,"Drinks,Alcohol, Beverages" 334 | Root beer,12 oz.,346,140,0,0,0,0,35,"Drinks,Alcohol, Beverages" 335 | Coffee,1 cup,230,3,t,0,0,0,1,"Drinks,Alcohol, Beverages" 336 | Tea,1 cup,230,4,0,t,0,0,1,"Drinks,Alcohol, Beverages" 337 | -------------------------------------------------------------------------------- /examples/us_army_recipes.txt: -------------------------------------------------------------------------------- 1 | The Project Gutenberg eBook of Recipes Used in the Cooking Schools, U. S. Army 2 | 3 | This ebook is for the use of anyone anywhere in the United States and 4 | most other parts of the world at no cost and with almost no restrictions 5 | whatsoever. You may copy it, give it away or re-use it under the terms 6 | of the Project Gutenberg License included with this ebook or online 7 | at www.gutenberg.org. If you are not located in the United States, 8 | you will have to check the laws of the country where you are located 9 | before using this eBook. 10 | 11 | Title: Recipes Used in the Cooking Schools, U. S. Army 12 | 13 | 14 | Creator: United States. Army 15 | 16 | Release date: May 4, 2021 [eBook #65250] 17 | 18 | Language: English 19 | 20 | Credits: MFR, Quentin Campbell and the Online Distributed Proofreading Team at https://www.pgdp.net (This file was produced from images generously made available by The Internet Archive) 21 | 22 | 23 | *** START OF THE PROJECT GUTENBERG EBOOK RECIPES USED IN THE COOKING SCHOOLS, U. S. ARMY *** 24 | 25 | Transcriber’s Note 26 | 27 | The punctuation, hyphenation and unusual spelling of the original text 28 | has been retained in this transcription. Correction of a typographical 29 | error is as noted at the end. 30 | 31 | Bold text is denoted by =equal signs= while small capitals in the 32 | original text have been transcribed as ALL CAPITALS. 33 | 34 | ————————————————— Start of Book ————————————————— 35 | 36 | 37 | 38 | 39 | RECIPES 40 | 41 | USED IN THE 42 | 43 | COOKING SCHOOLS, 44 | 45 | U. S. ARMY. 46 | 47 | 48 | [Illustration] 49 | 50 | 51 | WASHINGTON: 52 | GOVERNMENT PRINTING OFFICE, 53 | 1906. 54 | 55 | 56 | 57 | 58 | CONTENTS. 59 | 60 | —————— 61 | 62 | Page. 63 | Title page 1 64 | 65 | RECIPES. 66 | SOUPS: 67 | Bean 7 68 | Beef 7 69 | Bouillon 7 70 | Pea 7 71 | Potato 8 72 | Rice 8 73 | Spanish 8 74 | Tomato, cream 8 75 | Tomato and corn 9 76 | Vegetable 9 77 | FISH AND OYSTERS: 78 | Codfish balls 9 79 | Salmon, boiled 9 80 | Salmon, creamed, on toast with egg sauce 10 81 | Salmon croquettes 10 82 | Oyster potpie 10 83 | SAUCES: 84 | Army 11 85 | Army chocolate 11 86 | Cream 11 87 | Egg 11 88 | Spanish 11 89 | Tomato, for baked beans 12 90 | Tomato, cream 12 91 | White 12 92 | GRAVIES: 93 | Browned flour for 12 94 | Burnt sugar 12 95 | Cream 12 96 | MEATS: 97 | Bacon and Pork— 98 | Bacon 13 99 | Bacon and liver 13 100 | Boston baked pork and beans 13 101 | Beef— 102 | A la mode 13 103 | Boiled 14 104 | Boiled (corned) and cabbage 14 105 | Croquettes 14 106 | Fritters 14 107 | Hash 15 108 | Hearts stuffed with bread dressing 15 109 | Loaf 15 110 | Roast 15 111 | Steak, broiled 16 112 | Steak and onions 16 113 | Stewed 16 114 | Stew with dumplings 17 115 | Chili con carne 17 116 | Crepinettes de veau 17 117 | Hamburger steak 16 118 | Mutton potpie 18 119 | Pot roast 18 120 | VEGETABLES: 121 | Baked beans 18 122 | Potatoes— 123 | Baked 18 124 | Baked, sweet, and apples 19 125 | Balls 19 126 | Boiled 19 127 | Creamed 19 128 | Escalloped 21 129 | Fried 20 130 | German fried 20 131 | Lyonnaise 20 132 | Mashed 20 133 | Salad 20 134 | Saratoga 21 135 | Mush— 136 | Fried 21 137 | Indian corn meal 22 138 | Macaroni and cheese 22 139 | BREAD: 140 | Corn 22, 23 141 | Dressing 23 142 | French toast or fried 23 143 | Rye and graham 24 144 | Biscuits— 145 | English tea 24 146 | For twenty men 24 147 | Cakes— 148 | Buckwheat 24 149 | New England corn johnny 25 150 | White-bread batter 25 151 | Muffins— 152 | Corn meal 25 153 | Graham gems 25 154 | Hot 26 155 | PUDDINGS, ETC. 156 | Apple 26 157 | Apple dumplings 26 158 | Apple fritters 26 159 | Apple roll 26 160 | Apple stewed or apple sauce 27 161 | Cornstarch 27 162 | Cracker 27 163 | Custard 28 164 | Custard bread 28 165 | English plum 28 166 | Fruit 28 167 | Peach 29 168 | Peach fritters 29 169 | Plum 29 170 | Rice 30 171 | Tapioca 30 172 | SAUCE: 173 | For apple fritters 30 174 | Brandy 31 175 | DESSERTS: 176 | Cakes— 177 | Ginger 31 178 | Griddle 31 179 | Rice 32 180 | Ginger snaps 31 181 | Ice cream, cheap 32 182 | Lemon sherbet 32 183 | Orange sherbet 33 184 | Pie— 185 | Apple 33 186 | Pumpkin 33 187 | Prunes, stewed 34 188 | COFFEE: 189 | Party 34 190 | Soldier’s 34 191 | 192 | 193 | 194 | 195 | RECIPES USED IN THE COOKING 196 | SCHOOL, U. S. ARMY. 197 | 198 | —————————— 199 | 200 | SOUPS. 201 | 202 | 203 | ### Bean soup (for 20 men). 204 | 205 | Take 3 pounds beans and soak overnight in about 2 quarts of water. When 206 | ready to make the soup add 2 quarts of boiling water and let boil for 207 | about 2 hours, or till done. Add ¼ pound fine chopped onions and season 208 | with salt and pepper to taste. Strain thru a collander. Put on the 209 | stove and let come to a boil, then it is ready to serve. 210 | 211 | 212 | ### Beef stock. 213 | 214 | Select beef bones and pieces of meat not used for any special purpose, 215 | place in a boiler of cold water, and stand on back of stove and let 216 | simmer. At end of about 6 hours strain into another vessel and it is 217 | then ready for use. 218 | 219 | 220 | ### Bouillon soup (for 20 men). 221 | 222 | Take 5 quarts beef stock, put on stove and let come to boil; add 1 223 | onion, chopped fine, salt and pepper to taste. Add 2 tablespoonfuls 224 | burnt sugar and strain thru fine strainer and serve “en crotons.” 225 | 226 | 227 | ### Pea soup (for 20 men). 228 | 229 | Take 2 quarts peas, 3 quarts of water, salt and pepper, 1 can 230 | evaporated cream, onions. Boil peas until soft, and strain thru a 231 | collander. Slice and fry 2 or 3 onions in brown grease until brown. 232 | Add cream, onions, and beef stock to the pea soup. Salt and pepper to 233 | taste. 234 | 235 | 236 | ### Rice soup. 237 | 238 | Take 4 pounds rice, 5 gallons beef stock, salt and pepper to taste. 239 | Boil for 4 hours. 240 | 241 | 242 | ### Potato soup (for 20 men). 243 | 244 | Take 10 or 12 potatoes, boil, mash, and mix them with a quart of 245 | boiling milk or cream. Have a well-seasoned soup stock ready, made 246 | with beef and veal bones and the usual vegetables. Ham bones can also 247 | be used. Slightly thicken it while boiling, which will prevent the 248 | potatoes from settling to the bottom. Mix 4 quarts of this stock with 249 | the potato cream, strain all, and season well; add a sprinkling of 250 | parsley and keep hot without boiling. Cost of 7 quarts, 40 cents. 251 | 252 | 253 | ### Spanish soup (for 20 men). 254 | 255 | Take 4 quarts beef stock, 1 can tomatoes, 2 medium-sized onions chopped 256 | fine, 2 or 3 chili peppers chopped fine, a little Cayenne pepper; put 257 | on stove and let boil or simmer for about 1 hour. Season with salt to 258 | taste and keep hot till served. No thickening in any soups. Strain this 259 | soup or not as desired. 260 | 261 | 262 | ### Cream tomato soup (for 20 men). 263 | 264 | Take 2 quarts beef stock, 2 cans tomatoes, 2 ounces onions chopped 265 | fine, 2 ounces sugar, salt and pepper to taste. Let boil about 1 hour. 266 | When cooked strain thru a collander. Just before serving add ½ can of 267 | cream: then serve. 268 | 269 | 270 | ### Vegetable soup. 271 | 272 | One-half boilerful cabbage (2 heads) chopped; potatoes, 3 pounds, raw, 273 | chopped; 3 pounds chopped onions; 2 cans tomatoes; and 1 pound rice. 274 | Put in with beef stock and cook not less than 4 hours. Thickening 275 | (flour), salt and pepper to taste. 276 | 277 | 278 | ### Corn and tomato soup (for 15 men). 279 | 280 | Take 1 quart green corn, cut off the cob; 1 quart tomatoes, cut small; 281 | 1 pint mixt vegetables, cut small; in 5 quarts seasoned beef stock. 282 | Boil up and season to taste. Cost of 7 quarts, 40 cents. 283 | 284 | 285 | 286 | 287 | FISH AND OYSTERS. 288 | 289 | 290 | ### Codfish balls (for 20 men). 291 | 292 | Take 3 pounds codfish, put in cold water and soak overnight before 293 | being used. Put in boiler the codfish with about 3 quarts cold water 294 | and let boil ½ hour. Drain the water from the codfish and pick out 295 | bones, or meat from bones. Run it thru hash machine. Take 5 pounds 296 | cold boiled potatoes, run thru hash machine; add pepper, parsley, and 297 | seasoning. Work the ingredients all well together and roll into 2-ounce 298 | balls. Make a batter of 2 eggs and a little milk. Dip the balls into 299 | the batter, then into cracker dust, and fry in hot boiling lard till 300 | nice brown color. Serve hot. 301 | 302 | 303 | ### Boiled Salmon. 304 | 305 | Put 5 cans salmon, open, in pan of hot water, and let remain on stove 306 | till heated thru. Make a cream sauce of 3 quarts beef stock, 1 can 307 | evaporated cream, salt and pepper, and parsley to taste. Put on stove 308 | and let come to a boil. Mix ½ pound white flour in 1 pint water and 309 | thicken the mixture. Turn the salmon out on a large platter and pour 310 | over the white sauce and serve hot. Can either be served on toast or 311 | not. 312 | 313 | 314 | ### Creamed salmon on toast with egg sauce (for 20 men). 315 | 316 | Make cream sauce, adding eggs. Take 5 cans salmon, remove from cans and 317 | put in vessel with about 1 pint beef stock and let come to a boil. Make 318 | an egg sauce: 2 quarts beef stock, 1 quart milk (1 can evaporated cream 319 | makes ½ gallon milk). Thicken with ¼ pound flour, season with salt and 320 | pepper, set on stove, let come to a boil and it is then ready for use. 321 | Egg sauce: Add 4 hard-boiled eggs, chopped fine; toast some stale bread 322 | 2 or 3 inches square, lay neatly on a dish. Put the salmon on top of 323 | toast, pour sauce over, then serve. Garnish if desired. 324 | 325 | 326 | ### Salmon croquettes (for 20 men). 327 | 328 | Take 4 cans salmon, 4 pounds cold boiled potatoes, 2 eggs, season with 329 | salt and pepper. Grind thru hash machine. Roll into cakes about 2 330 | inches in diameter, like biscuits. Make an egg batter of 2 eggs and a 331 | little milk. Dip each salmon ball into the batter and then into cracker 332 | dust. Fry in deep hot lard, same as fish balls or doughnuts. Serve hot. 333 | 334 | 335 | ### Oyster potpie (for 20 men). 336 | 337 | Make crust as follows: Take 3 pounds flour, 1 pound lard, 2 ounces 338 | baking powder, 2 ounces salt, and water enough to make a stiff dough. 339 | This does for any kind of meat pie. Take 3 cans oysters, fresh or cove 340 | oysters, 1 quart milk, ¼ pound butter, ¼ bunch parsley. Put on stove 341 | and let come to a boil. Thicken with ¼ pound flour, mixt in ½ pint cold 342 | water. Should be baked about ¾ hour. 343 | 344 | 345 | 346 | 347 | SAUCES. 348 | 349 | 350 | ### Army sauce. 351 | 352 | Take 2 quarts beef stock, thicken with ¼ pound mixt flour, salt and 353 | pepper to taste. Add 2 tablespoonfuls burnt sugar. Sugar should first 354 | be dissolved in water, as it is better. This is used over fish, steaks, 355 | and chops. 356 | 357 | 358 | ### Army chocolate sauce. 359 | 360 | Take ½ dish pan water, 2 pounds sugar, 3 ounces chocolate, and ½ pound 361 | cornstarch. 362 | 363 | 364 | ### Cream sauce. 365 | 366 | Made the same as apple-fritter sauce. 367 | 368 | 369 | ### Egg sauce. 370 | 371 | Put on to boil 2 quarts water, ½ can cream, 2 ounces lard, salt and 372 | pepper. Thicken with ¼ pound flour. When done chop 4 hard-boiled eggs 373 | fine. Then serve. 374 | 375 | 376 | ### Spanish sauce (for 20 men). 377 | 378 | Take saucepan and put in 1 pint beef stock, 2 cans tomatoes, 4 chili 379 | peppers chopped fine, 2 ounces onions chopped fine, 1 tablespoonful 380 | salt, ¼ ounce black pepper, 2 or 3 dashes red pepper, 2 tablespoonfuls 381 | browned sugar, 1 ounce lard or butter. Set on stove and let simmer 382 | about 2 hours or till done. 383 | 384 | 385 | ### Tomato sauce for baked beans. 386 | 387 | Take 5 cans tomatoes, mash up with hands, add 2 pounds onions, chopped, 388 | ½ gallon vinegar, 1 pound sugar (dissolved in vinegar), salt and pepper 389 | to taste, 1 teaspoonful each Cayenne pepper, cinnamon, and cloves. 390 | 391 | 392 | ### Tomato cream sauce. 393 | 394 | Made exactly like Spanish sauce with 1 can cream added. 395 | 396 | 397 | ### White sauce (for 20 men). 398 | 399 | Take 2 quarts beef stock, 2 ounces butter, ½ can cream, ¼ pound flour 400 | with cold water to thicken. Set all on stove until boils, then add the 401 | flour till thickened. Salt and pepper to taste. 402 | 403 | 404 | 405 | 406 | GRAVIES. 407 | 408 | 409 | ### Brown flour for gravy. 410 | 411 | Roast flour the same as roasting coffee. 412 | 413 | 414 | ### Cream gravy. 415 | 416 | Take ⅔ pan beef stock, 1 can cream, salt and pepper, and thicken with 417 | flour, a little butter if on hand. 418 | 419 | 420 | ### Burnt sugar. 421 | 422 | Made by frying ½ pound sugar in a pan. Let remain on stove and boil for 423 | about 15 minutes. When the color of the sugar is a dark brown pour in 1 424 | quart hot water and let simmer about 15 minutes till done. 425 | 426 | 427 | 428 | 429 | MEATS. 430 | 431 | 432 | BACON AND PORK. 433 | 434 | ### Bacon. 435 | 436 | Bacon should be soaked in cold water about 2 or 3 hours, cut thin, and 437 | fried crisp. 438 | 439 | 440 | ### Liver and Bacon. 441 | 442 | Cut liver in thin slices the day before. Wash liver and let soak in 443 | cold water, drain liver and let dry out in sack or towel. Salt and 444 | pepper liver and put in flour. Fry bacon, then fry your liver in bacon 445 | grease. One pound of bacon to 2 pounds of liver. 446 | 447 | 448 | ### Boston baked pork and beans (for 20 men). 449 | 450 | Take 5 pounds beans, put into soak overnight and boil for 2 hours next 451 | morning. Then draw water and put into baking pan. Season with salt (2 452 | ounces), 1 quart molasses. Slice 4 pounds bacon and put in oven and let 453 | bake 2 hours. When done they should be a chocolate-brown color. 454 | 455 | 456 | BEEF. 457 | 458 | ### Beef a la mode (for 20 men). 459 | 460 | Take 8 pounds raw beef, cut in slices ½ inch thick by 4 inches square. 461 | Take a dishpan, set on stove, and cover meat with 4 quarts beef stock 462 | and let it simmer till well done. Add 1 can tomatoes, 2 onions chopped 463 | fine, and let cook for ½ hour. Season with salt and pepper. Take 1 464 | pound browned flour and mix with 1 quart cold water, pour over the beef 465 | and let cook till thickened. Add ½ gill vinegar and serve hot. 466 | 467 | 468 | ### Boiled beef (for 20 men). 469 | 470 | Take a bake pan and set on stove, put in 3 quarts cold water, 8 pounds 471 | beef, cut in four pieces, and let boil for about 2 hours or until done. 472 | Then pour white sauce over beef and serve. 473 | 474 | 475 | ### Boiled beef (corned) and cabbage (for 20 men). 476 | 477 | Take 8 pounds corned beef soaked overnight, remove the water, add about 478 | 4 gallons fresh cold water to draw the salt out. Let boil about 1 hour, 479 | then add 8 pounds cabbage, cut in quarters and thoroly washt in cold 480 | water, and let boil about 2 hours longer, and will then be ready to 481 | serve. 482 | 483 | 484 | ### Beef croquettes. 485 | 486 | Take 3 pounds cold beef, cooked, pass thru hash machine; ¼ pound onions 487 | chopped fine; season with salt, pepper, and mace. Make a white sauce: 488 | 1 pint beef stock, 2 ounces butter, thickened with ¼ pound white flour 489 | in ½ pint water; pour the sauce over the meat. Set aside and let cool. 490 | Roll into croquettes about 2 inches in diameter. Beat up 2 eggs, dip 491 | the croquettes into the eggs, then into cracker dust. Fry in deep hot 492 | lard same as doughnuts. 493 | 494 | 495 | ### Beef fritters (for 20 men). 496 | 497 | Take 2 pounds flour, 2 ounces baking powder, 6 eggs, 1 quart cold 498 | water, 3 pounds beef, cooked, ground thru hash machine. Stir this 499 | mixture all together and beat to consistency of fritter dough. Serve 500 | with brown gravy. 501 | 502 | 503 | ### Beef hash. 504 | 505 | Take 3 pounds cooked meat ground in machine, 1 pound onions ground in 506 | machine, and 5 pounds potatoes ground in machine. Season with salt, 507 | pepper, and ground sage to taste, adding 3 quarts stock. Put in oven 508 | and bake brown till done—about 2 hours. 509 | 510 | 511 | ### Beef hearts, stuffed with bread dressing (for 20 men). 512 | 513 | Take 3 beef hearts, thoroly washt in cold water, and dry thoroly. Then 514 | make a bread stuffing as follows: Two loaves stale bread soaked in 515 | about 1 quart cold water for about 15 minutes, 2 ounces chopped onions, 516 | salt and pepper and ground sage to taste, ½ pound lard; thoroly mix the 517 | stuffing together and stuff the hearts with this mixture. Put neatly in 518 | a bake pan with a little grease and about 2 quarts beef stock. Let bake 519 | about 2 hours, basting frequently. Slice and serve. 520 | 521 | 522 | ### Beef loaf (for 20 men). 523 | 524 | Take 6 pounds raw beef ground fine, 1 pound onions chopped fine, 525 | 1 pound cracker dust ground fine, 4 eggs, salt and pepper, 4 526 | chili peppers, and 1 pint beef stock, all mixt thoroly and molded 527 | into 3-pound loaves, and put in oven and baked for 2 hours. Baste 528 | frequently. When baked, loaves are sliced and served either hot or cold. 529 | 530 | 531 | ### Roast beef. 532 | 533 | Cut in pieces. Place in pan. Salt and pepper to taste. Cover beef with 534 | a little flour to brown beef. Pour in a little water to keep moist and 535 | furnish water for gravy. Roast from 2 to 3 hours, depending upon sizes 536 | of pieces of beef. Baste well. 537 | 538 | 539 | ### Broiled beefsteak. 540 | 541 | Grease meat and place on top of stove to cook. Turn frequently until 542 | done, well done, or rare, as desired. Salt and pepper and add a little 543 | butter on top. Cover steak and put away. 544 | 545 | 546 | ### Beefsteak and onions (for 20 men). 547 | 548 | Take 8 pounds beef, cut in steaks ½ inch thick. Put a frying pan on 549 | stove with a little grease and fry about 20 minutes, or till done. 550 | After the steaks are dished up, put the onions in the hot grease and 551 | let fry 15 minutes, or till done. Onions served on top of beefsteaks. 552 | 553 | 554 | ### Hamburger steak (for 20 men). 555 | 556 | Take 5 pounds raw beef, ground or chopped, 2 pounds onions, season with 557 | salt and pepper. Mix all together and roll out in round balls of 2 or 3 558 | ounces, and either put in oven and bake, or fry like doughnuts in deep 559 | hot pot. Serve. 560 | 561 | 562 | ### Stewed beef (for 20 men). 563 | 564 | Take 8 pounds raw beef or cooked beef, cut in strips about 2 inches 565 | long, put in bake pan, pour over 5 quarts of beef stock, 2 ounces 566 | onions chopped, ½ bunch parsley, salt and pepper to taste, thicken with 567 | ½ pound flour mixt in about 1 pint water, 2 tablespoonfuls burnt sugar, 568 | to color the mixture, and let simmer on the stove for about 2 hours, or 569 | till done. 570 | 571 | 572 | ### Beef stew with dumplings. 573 | 574 | Take 5 pounds raw beef, cut into pieces 1 inch square, 5 pounds 575 | potatoes diced about 1 inch square, 1 can tomatoes, and season with 576 | salt and pepper. Put all ingredients in a pan. Place in about 3 577 | quarts beef stock, put on stove, and let cook for about 1½ hours. 578 | Make dumplings batter of 2 pounds flour, 3 eggs, 1 pint milk, 2 579 | tablespoonfuls baking powder, a little salt and pepper, mix all 580 | together thoroly. Drop in the hot mixture about the size of a hickory 581 | nut and let boil about 15 minutes, and then serve good and hot. 582 | 583 | 584 | ### Chili con carne (for 20 men). 585 | 586 | Take 4 pounds cold boiled meat, cut into about ½-inch dices, put into 587 | baking pan enough bacon grease to cover the bottom of pan, chop about 588 | 2 pounds onions fine, and put the onions and beef in the hot greased 589 | frying pan. Let the meat and onions brown nice brown color; chop fine 590 | about 3 ounces chili peppers, put into the mixture and let simmer for 591 | about 1 hour. Take about 5 pounds cold boiled beans, grind them thru 592 | hash machine and add to the boiled mixture; let simmer about ½ hour. 593 | Season with salt, pepper, and ground cloves. Add about 3 tablespoonfuls 594 | burnt sugar and let simmer 20 minutes longer and serve hot, either on 595 | toast or without. 596 | 597 | 598 | ### Crepinettes de veau. 599 | 600 | Take ⅔ cold cooked meat, ⅓ raw beef without fat. Chop into sausage 601 | meat; season with powdered sage, salt, and plenty of black pepper. Make 602 | into little cakes and fry brown on both sides shortly before wanted. 603 | Serve with gravy. Sixteen pounds cooked meat and 8 pounds raw beef 604 | enough for 80 men. 605 | 606 | 607 | ### Mutton potpie (for 20 men). 608 | 609 | Take 6 pounds mutton chopped in small pieces, 5 pounds potatoes chopped 610 | in small pieces, 1 can tomatoes, 2 or 3 onions, and salt and pepper 611 | to taste. Thicken with browned flour in 4 quarts water, 2 quarts beef 612 | stock. All cooked together, slowly, in open pan for about 2 hours. 613 | Crust same as for oyster potpie. 614 | 615 | 616 | ### Pot roast (for 20 men). 617 | 618 | Take 8 pounds beef, put on stove in deep kettle and let brown for about 619 | 20 minutes. Then add 1 pint beef stock, salt and pepper to taste, and 2 620 | onions chopped fine, and let simmer for about 2 hours until done. Turn 621 | frequently. 622 | 623 | 624 | 625 | 626 | VEGETABLES. 627 | 628 | 629 | ### Baked beans (for 100 men). 630 | 631 | Take 25 pounds dry beans that have been soaked overnight and drain off 632 | the water, cover them (little over) with fresh water and boil for 1 633 | hour. This water will cook beans well. Divide them in 2 large bake pans 634 | and season with salt and pepper and 7 pounds bacon, diced, ½ gallon 635 | molasses, and bake at least 3 hours. 636 | 637 | 638 | POTATOES. 639 | 640 | ### Baked potatoes. 641 | 642 | Peel potatoes, wash thoroly, and place in shallow pan, season with salt 643 | and pepper, add 1 sliced onion, sprinkle with a little flour. Put in a 644 | little lard and beef stock. Bake in oven until done. 645 | 646 | 647 | ### Baked sweet potatoes and apples (for 80 men). 648 | 649 | Take 30 pounds sweet potatoes and 12 pounds apples. Boil potatoes 650 | about 2 minutes; then peel and slice carefully. Boil apples 1 minute; 651 | then peel, core, and slice. Take greased bake pan and put in layer of 652 | potatoes, then layer of apples, and so on. Put over all a little butter 653 | or beef suet. If apples are too sour, add a little brown sugar. Bake 654 | all in pan until done and serve warm. 655 | 656 | A little expensive, but an excellent holiday dish. 657 | 658 | 659 | ### Potato balls (for 90 men). 660 | 661 | Mash about 25 pounds boiled potatoes, season with salt and pepper, and 662 | add a little milk. Make into small balls and put into a pan with very 663 | little grease and brown on both sides. 664 | 665 | 666 | ### Boiled potatoes (for 20 men). 667 | 668 | Take 10 pounds potatoes, thoroly washt, and put in a tin boiler and 669 | cover with cold water and let boil ½ hour. After water boils, stick a 670 | fork into 1 or 2 potatoes; if fork enters easily, they are done. Remove 671 | from stove and pour the water off and serve good and hot, with or 672 | without skins. 673 | 674 | 675 | ### Creamed potatoes. 676 | 677 | Take 8 pounds raw potatoes, diced in 1-inch pieces, boil until done, 678 | then pour water off; add 1 quart cold water, 1 can cream, and a little 679 | parsley, salt and pepper, and thicken with ½ pound white flour mixt in 680 | 1 pint cold water, then serve. 681 | 682 | 683 | ### Fried potatoes. 684 | 685 | Boil with peelings on, then slice and fry in lard; salt and pepper to 686 | taste. 687 | 688 | 689 | ### German fried potatoes (for 20 men). 690 | 691 | Take 8 pounds cold boiled potatoes, cut in round slices; add 2 pounds 692 | onions chopped fine, salt and pepper to taste. Put in about ½ pound 693 | lard and fry to nice brown color and serve hot. 694 | 695 | 696 | ### Lyonnaise potatoes. 697 | 698 | Boil 30 pounds potatoes and cut up. Mix in 5 pounds raw onions and 699 | little grease or lard. Bake in oven till done and browned. 700 | 701 | 702 | ### Mashed potatoes. 703 | 704 | Take boiled potatoes, peel, mash well, adding cream, salt, and pepper. 705 | 706 | 707 | ### Potato salad (for 20 men). 708 | 709 | Take 6 pounds cold boiled potatoes diced in ¼-inch pieces; 2 pounds 710 | onions, raw, chopped fine; 1 bunch parsley chopped fine; season with 711 | salt and pepper. Make a French dressing as follows: 1 pint vinegar, 712 | 2 tablespoonfuls sugar (brown or white), 2 or 3 dashes red pepper, 713 | 1 ounce dry mustard, ½ pound bacon chopped fine and fried. Pour the 714 | vinegar mixture on the hot bacon and grease. Then set back on stove to 715 | keep warm, and when ready to serve pour the vinegar, grease, etc., over 716 | the potatoes, etc., then serve. 717 | 718 | 719 | ### Saratoga potatoes. 720 | 721 | Dice potatoes raw, boil them until done, then drain and set away and 722 | let cool. When cool fry in butter or lard until nice and brown. Add 723 | parsley and chopped onions, 1 quart rich milk. Thicken with ¼ pound 724 | flour. Season with salt and pepper and serve hot. 725 | 726 | 727 | ### Escalloped potatoes (for 100 men). 728 | 729 | Take 35 pounds cold boiled potatoes, 8 pounds cheese, 8 cans condensed 730 | milk, and 3 or 4 basting-spoonfuls of flour. Pare potatoes and slice 731 | them. Grate cheese fine and mix cheese evenly with potatoes in bake 732 | pan. Mix flour with milk and dilute milk with water until potatoes are 733 | covered. Bake in slow oven. 734 | 735 | It is sometimes thought to be an improvement to use less cheese and a 736 | much larger quantity of finely ground beef suet. 737 | 738 | 739 | ### Fried mush (for 20 men). 740 | 741 | Take 2 quarts beef stock, 2 quarts water, 1 ounce salt, and set on 742 | stove and let boil for 4 or 5 minutes. Add 2 pounds corn meal. Put the 743 | meal in a flour sieve and shake it gradually, stirring it thoroly all 744 | the time, until it commences to thicken. Then set on back part of stove 745 | and let simmer for about 1 hour or till done, when it drops freely from 746 | the paddle. Pour into dish pan about 1 inch deep and set aside to cool. 747 | When cool cut into 2-inch squares. Have about ½ pound lard in frying 748 | pan. Fry to nice brown color. Serve hot with sirup. 749 | 750 | 751 | ### Indian corn meal mush. 752 | 753 | Take 5 ounces corn meal, 2 quarts boiling water, 1 ounce salt. Mix corn 754 | meal with cold water before putting it in, to prevent lumping. Stir in 755 | slowly but be careful to keep the water boiling. Cover closely and let 756 | boil 2½ hours. Stir frequently, to prevent scorching. Take off when 757 | thick and let cool. Eight pounds corn meal enough for 80 men. 758 | 759 | 760 | ### Macaroni and cheese (for 80 men). 761 | 762 | Break 14 pounds macaroni into convenient lengths and put into boiler of 763 | boiling salted water. Use eight or ten times as much water as macaroni. 764 | Boil from 20 to 30 minutes, until tender. Draw off water and pour 765 | macaroni into a well-greased bake pan and bake in a moderate oven 1½ 766 | hours or until done, then cover with the following dressing: Two cans 767 | tomatoes, 2 gallons beef stock, salt and pepper to taste, teaspoonful 768 | thyme or a little bay leaves, and a little suet or butter. Put all the 769 | dressing in a small boiler on fire and keep stirring until ingredients 770 | are well incorporated. Pass dressing thru a sieve and pour over 771 | macaroni. Grate over macaroni and sauce 6 or 8 pounds cheese. 772 | 773 | 774 | 775 | 776 | BREAD, BISCUITS, ETC. 777 | 778 | 779 | ### Corn bread (for 20 men). 780 | 781 | Take 2½ pounds white flour, 2½ pounds corn meal, ¼ pound butter, ¼ 782 | pound lard, 2 ounces baking powder, 1 quart milk, 8 eggs (yolks and 783 | whites) beaten separately, 1 ounce salt, 2 ounces brown sugar. Mix all 784 | thoroly together. Grease a bake pan well and pour in the mixture and 785 | let bake about 45 minutes or till done. Test with a broom straw into 786 | center of cake. If it comes out clean and dry it is done; if wet or 787 | stuff sticks, not done. 788 | 789 | 790 | ### Corn bread (for 15 men). 791 | 792 | Take 2 heaping cups yellow corn meal, 1 cup flour, 3 eggs, 2½ cups 793 | sweet milk, 1 teaspoonful lard, 2 tablespoonfuls sugar, 3 teaspoonfuls 794 | baking powder, 1 teaspoonful salt. Beat eggs thoroly, whites and yolks 795 | separately. Sift baking powder with corn meal and flour. Melt lard, add 796 | the last. Beat fast and thoroly. Bake ½ hour in greased pan. 797 | 798 | 799 | ### Bread dressing (for 20 men). 800 | 801 | Take 5 pounds stale bread, put in cold water and let soak 15 minutes, 802 | then drain off the water. Have chopped fine 2 pounds raw onions; 1 803 | ounce sage, ground; salt and pepper to taste; ½ pound lard, butter, 804 | suet, or bacon grease. Thoroly mix together and set in oven and let 805 | bake about 1 hour. When ready to dish up pour 2 quarts beef stock over 806 | the dressing and then serve. 807 | 808 | 809 | ### French toast or fried bread (for 20 men). 810 | 811 | Take 2 loaves old bread left, and cut in slices. Beat 3 eggs well 812 | together. Add ½ pint milk, and season with salt and pepper. Add 2 813 | tablespoonfuls of sugar. Put on stove in frying pan with 2 ounces 814 | butter. Dip the slices of bread in the egg batter and put in pan and 815 | fry a nice brown. Serve hot. 816 | 817 | 818 | ### Rye and graham bread. 819 | 820 | Take ½ wheat flour, ½ graham (or rye) flour, add 1 quart molasses for 821 | 100 pounds dough. Use sponge and dough system. Make sponge of wheat 822 | flour. 823 | 824 | 825 | ### English tea biscuit (for 80 men). 826 | 827 | Take 16 pounds flour, 2 pounds lard, 2 quarts cold water, 3 pounds 828 | granulated sugar, 2 ounces caraway seed, 2 ounces ammonia, “for baker’s 829 | use,” 2 ounces baking powder. Cut with regular or fancy cutters. Bake 830 | in moderate oven. Ammonia “for baker’s use” can be had in any reliable 831 | drug store, 4 ounces for 10 cents. 832 | 833 | 834 | ### Biscuits (for 20 men). 835 | 836 | Take 4 pounds flour, 2 pounds lard, 2 ounces baking powder, 3 quarts 837 | water (cold), 1 ounce salt. Mix together like dough, making medium 838 | stiff dough. Grease pan before putting in biscuits. Roll dough ½ inch 839 | thick. Place in pan close together and bake for 15 minutes or till they 840 | are twice their original size. 841 | 842 | Before baking biscuits punch them with a fork to have them hold their 843 | shape. 844 | 845 | 846 | ### Buckwheat cakes (for 20 men). 847 | 848 | Take 4 pounds self-raising buckwheat flour and mix with cold water till 849 | it will pour easily from spoon. Add 1 ounce salt. Have cake griddle 850 | well greased and hot. Bake for about 5 minutes. When done on one side 851 | turn over and send to table good and hot. Butter and sirup used to eat 852 | with cakes. 853 | 854 | 855 | ### New England corn johnnycake (for 80 men). 856 | 857 | Take 7 pounds corn meal, 7 pounds flour, 2 pounds granulated sugar, 1½ 858 | pounds lard, 4 ounces salt, 3 cans evaporated cream, 18 eggs, 12 ounces 859 | baking powder. Rub in lard with hand and make a fine batter with cold 860 | water. When well mixt pour into a well-greased pan. Bake at once in a 861 | moderate oven. 862 | 863 | NOTE.—Eggs may be reduced if baking powder is increased. 864 | 865 | 866 | ### White-bread batter cakes (for 80 men). 867 | 868 | Take 8 pounds bread crumbs, 6 pounds flour, 8 eggs, 4 tablespoonfuls 869 | baking powder, 1½ ounces salt, cold water or milk to mix it. Remove all 870 | dark crusts from the bread and soak in cold water until soft, press 871 | out dry, mash smooth, add flour, water (or milk), eggs, and powder. It 872 | always improves batter cakes to beat the eggs light before mixing them 873 | in. No shortening or sirup needed for above. Cost 60 cents. 874 | 875 | 876 | ### Corn-meal muffins (for 90 men). 877 | 878 | Take 4 pounds flour, 6 pounds corn meal, 3 pounds sugar, 1 dozen eggs, 879 | 4 tablespoonfuls baking powder, 2 ounces salt, and about 1 gallon 880 | water. Mix up to thin dough and bake. 881 | 882 | 883 | ### Graham gems or muffins (for 20 men). 884 | 885 | Take 2 pounds graham flour, 2 pounds wheat flour, ¼ pound melted 886 | butter, 1 ounce salt, 2 ounces baking powder, 6 eggs, 1 quart milk, and 887 | thoroly beat these ingredients. Have gem pans nicely greased. Pour in 888 | the batter and fill gem pans about half full. Put in a very hot oven 889 | and bake 20 minutes. 890 | 891 | 892 | ### Hot muffins (for 20 men). 893 | 894 | Take 3 pounds flour, 1 ounce baking powder, ½ ounce salt, 3 ounces lard 895 | or butter, 3 eggs, and enough water or milk to make a batter to drop 896 | from spoon. Grease the gem pans or muffin mugs and fill mugs half full 897 | of dough and bake. 898 | 899 | 900 | 901 | 902 | PUDDINGS, ETC. 903 | 904 | 905 | ### Apple pudding (for 20 men). 906 | 907 | Same as peach pudding, except use apples instead of peaches. 908 | 909 | 910 | ### Apple dumplings. 911 | 912 | Take 5 pounds pie dough and roll out in strips about 6 by 4 inches, 913 | rather thin. Put on each strip a spoonful of stewed apples, evaporated 914 | (if green fresh apples use raw), and fold over the four corners and 915 | roll in a round ball. Put in oven and bake about 45 minutes or till 916 | done. Serve hot with a white sauce (sweet cream). 917 | 918 | 919 | ### Apple fritters (for 20 men). 920 | 921 | Take 4 pounds flour, 6 ounces baking powder, 1 ounce salt, 6 eggs 922 | broken in flour, 3 pints water, 1 can cream, 1 quart stewed apples. Mix 923 | all together. Add flour until it is thick enough to drop from spoon. 924 | Fry in hot lard like doughnuts. 925 | 926 | 927 | ### Apple roll (for 20 men). 928 | 929 | Take 3 pounds flour, 1 pound lard, 1 ounce baking powder, 2 ounces 930 | salt, mix with cold water, enough to make a thick dough, ½ pound dried 931 | apples, soak and cook. Roll out dough similar to cinnamon roll, place 932 | in greased bread pan. Break and beat an egg and paint rolls with this 933 | to brown color. The egg is not necessary, but it makes rolls look well. 934 | Place in oven and bake. 935 | 936 | 937 | ### Stewed apples or apple sauce (for 20 men). 938 | 939 | Take 1 quart water, 2 pounds apples, 1½ pounds sugar, 1 lemon, squeezed 940 | and peeling in, cinnamon and nutmeg to taste. Put all on stove and let 941 | cook about 1 hour. Soaking of apples not necessary. 942 | 943 | 944 | ### Cornstarch pudding (for 20 men). 945 | 946 | Take 1 pound cornstarch, 1 pound sugar (granulated), 3 quarts water, 947 | 1 quart cream or milk, 2 ounces salt, 1 tablespoonful cinnamon, 1 948 | teaspoonful nutmeg, 1 dozen eggs, when practicable. Heat water to 949 | a boiling point. Stir in cream, salt, sugar, cinnamon, and nutmeg. 950 | Dissolve the cornstarch in a small portion of the water and add the 951 | eggs, well beaten. Boil briskly for a few minutes, stirring often to 952 | avoid scorching. Set to cool in any kind of vessels, cups, vegetable 953 | dishes, etc. Flavor with lemon, etc., if desired. 954 | 955 | For baked cornstarch, pour this into a well-greased baking pan and bake 956 | about 1 hour in a moderate oven. Make a cream sauce for this. 957 | 958 | 959 | ### Cracker pudding. 960 | 961 | Take ½ dishpanful cracker meal (part bread soaked), water, 3 pounds 962 | sugar. Mix up 1 can cream and peaches, stewed, on top. Bake in oven. 963 | Sauce for same made as follows: 2 gallons water, 2 cans cream, 3 pounds 964 | sugar, 2 ounces salt, and 1 pound cornstarch. 965 | 966 | 967 | ### Custard pudding (for 20 men). 968 | 969 | Take 2 quarts milk, 1 quart water, ½ ounce salt, 6 eggs, 2 pounds 970 | sugar, and thoroly beat all together. Have a baking pan well greased 971 | and pour the mixture in and bake about ¾ hour or till it is done, then 972 | serve. Can either flavor it or not. The best way to test this pudding 973 | is to stick a straw in its center. If straw comes out clean it is done, 974 | if particles stick to straw it is not done. 975 | 976 | 977 | ### Custard bread pudding (for 20 men). 978 | 979 | Take 6 pounds stale or fresh bread, cut into small bits, 1 inch each 980 | way. Then make a custard of 2 quarts milk, 8 eggs, 1 pound granulated 981 | sugar, 1 nutmeg, a little salt (very little), ½ pound cornstarch. Put 982 | milk on stove and let come to boil, and add the other ingredients, and 983 | when it thickens it is done. Pour over the diced bread and serve hot. 984 | 985 | 986 | ### English plum pudding (for 80 men). 987 | 988 | Take 3 pounds raisins, 3 pounds currants, 1½ pounds brown sugar, 1 989 | pound orange peel, 3 pounds beef suet chopped fine and freed from 990 | fiber, 3 pounds flour, peel of 6 lemons, 1½ ounces mixt spices, 3 991 | pinches salt, 15 eggs, 1½ pints milk, 6 glasses brandy or best whisky. 992 | Mix well, tie up with cloth in cans, boil 5 or 6 hours. Serve with 993 | brandy sauce. 994 | 995 | 996 | ### Fruit puddings. 997 | 998 | Are exactly as the fruit rolls, only the crust is put in a pan the same 999 | as making a pie. Filling put in and cooked with a top crust. 1000 | 1001 | 1002 | ### Peach pudding (for 20 men). 1003 | 1004 | Take 3 pounds flour, 1 pound beef suet, 1 ounce salt, 1 quart milk, 2 1005 | ounces baking powder, 12 eggs, ½ pound sugar, and 1 pint cold water. 1006 | Beat these ingredients all well together to the consistency of a cake 1007 | batter dough (to drop easily from spoon). Have a well-greased pan, pour 1008 | the mixture, and let bake about 1 hour, or till done. Make a white 1009 | sauce as follows: 1 quart milk, 1 pint flour, 1½ pounds sugar, 2 pounds 1010 | stewed peaches, and set on stove. Let come to boil. Make thickening of 1011 | ½ pound cornstarch and 1 pint water, and pour into the mixture till it 1012 | thickens, and when ready to serve pour over pudding and set in the oven 1013 | for about 15 minutes to bake nice and brown. When done serve. 1014 | 1015 | 1016 | ### Peach fritters (for 20 men). 1017 | 1018 | Take 4 pounds flour, 6 ounces baking powder, 1 ounce salt, 6 eggs 1019 | broken in flour, 3 pints water, 1 can cream, 1 quart stewed peaches, 1020 | mix all together. Add flour until it is thick enough to drop from 1021 | spoon. Fry in hot lard like doughnuts. 1022 | 1023 | 1024 | ### Plum pudding (for 80 men). 1025 | 1026 | Take 3 pounds beef suet chopped fine and freed from fiber, 2¼ pounds 1027 | stale bread crumbs thoroly grated, ¾ pound brown sugar, rind of 3 1028 | lemons, ¾ pound flour, 3 pounds raisins, 3 pounds currants, 1½ pounds 1029 | citron, 2 nutmegs, 15 eggs, 1½ pints milk. Put in deep pan, mix well, 1030 | tie up with cloth in cans, boil 5 to 6 hours. Serve with cream sauce. 1031 | 1032 | Everything mentioned, except eggs, should be prepared the day before. 1033 | 1034 | Cost about $2.75. 1035 | 1036 | 1037 | ### Rice pudding (for 20 men). 1038 | 1039 | Put on stove in a tin boiler 1 pound of rice in 3 quarts of water. Let 1040 | boil about 1 hour or till done, then remove from stove and add 6 eggs, 1041 | ½ pound lard, 1 pound sugar, ½ pound currants, ½ pound raisins, and ½ 1042 | can cream diluted in 1 pint water. Season with nutmeg, cinnamon, and 1043 | salt. Grease a bake pan and put mixture into the oven and let cook for 1044 | about 1 hour or till done. 1045 | 1046 | 1047 | ### Tapioca pudding (for 20 men). 1048 | 1049 | Take 2 pounds tapioca and boil in 1 pint cold water for 20 minutes. 1050 | Remove from fire and add 1 quart fresh milk (cow’s), ¾ pound sugar, 1051 | nutmeg, cinnamon, salt, and ¼ pound butter, and 8 eggs well beaten all 1052 | together. Mix all thoroly together. Put in a pudding dish and bake ¾ 1053 | hour or till done, and serve with sweet cream sauce. 1054 | 1055 | 1056 | ### Sauce for apple fritters (for 20 men). 1057 | 1058 | Take 3 quarts boiling water, ¼ pound cornstarch, 1 can cream. Dissolve 1059 | starch in a little cold water to make creamy paste of it. Pour cream 1060 | in boiling water. Pour in cornstarch water when other water is boiling 1061 | well. Add 2 ounces butter, stir well. Remove from stove and add ¾ pound 1062 | granulated sugar, flour with a little nutmeg, cinnamon, lemon extract, 1063 | and pinch of salt. Serve hot with fritters. Fritters also hot. 1064 | 1065 | NOTE.—In frying fritters do not let particles of fritters remain in 1066 | grease; they will burn the grease. 1067 | 1068 | 1069 | ### Brandy sauce. 1070 | 1071 | Take some good melted butter with new sweet milk, according to amount 1072 | required. Sweeten to taste and add about 4 glasses of brandy. 1073 | 1074 | 1075 | 1076 | 1077 | DESSERTS. 1078 | 1079 | 1080 | ### Ginger cakes. 1081 | 1082 | Take 2 pounds lard, 4 pounds sugar, and rub together. Then add 2 dozen 1083 | eggs (3 at a time). Then put 4 ounces ginger in about 1 teaspoonful 1084 | cinnamon, 1 pinch salt, 1 gallon molasses, 1½ ounces soda (3 heaping 1085 | teaspoonfuls baking powder), 6 pounds flour. Make a cake dough. Slack 1086 | so as to drop from a spoon. Put in 2 bake pans and bake 25 or 30 1087 | minutes till done. 1088 | 1089 | 1090 | ### Griddle cakes (for 20 men). 1091 | 1092 | Take 3 pounds flour, 2 ounces baking powder, 1 ounce salt, 10 eggs, 1 1093 | can cream, 1 quart water. Mix to consistency of thick batter. Fry on 1094 | cake griddle with griddle greased with bacon rind or grease. 1095 | 1096 | 1097 | ### Ginger snaps (for 100 men). 1098 | 1099 | Take 16 pounds flour, 1 gallon molasses, 4 pounds sugar, 6 ounces 1100 | powdered ginger, 5 ounces ammonia “for baker’s use,” 4 ounces baking 1101 | soda, 2½ ounces salt, 2½ ounces powdered cinnamon. Cut with regular 1102 | cutter. When about to put in the oven cover the tops of the cakes 1103 | with a wet cloth. This will cause them to spread and present a fine 1104 | appearance. 1105 | 1106 | 1107 | ### Rice cakes No. 1 (for 80 men). 1108 | 1109 | Take 10 pounds rice flour, 2½ pounds granulated sugar, 2 pounds butter 1110 | or lard, 8 ounces baking powder, 2 cans cream. Roll upon pastry board 1111 | and shape into cakes with a cake cutter. Bake in a slow oven. 1112 | 1113 | One dozen eggs added to above will make a fine appearance. 1114 | 1115 | 1116 | ### Cheap ice cream (for 40 men, 6 men to 1 quart ice cream). 1117 | 1118 | Take 2 quarts milk, 5 pounds granulated sugar, 7 tablespoonfuls 1119 | cornstarch, 5 cans evaporated cream or 3 quarts fresh milk, 4 ounces 1120 | salt, 1 bottle flavoring extract. Boil the milk and cream, reserving 1121 | ¼ cup of milk. Mix the sugar, cornstarch, and salt thoroly together, 1122 | add cold milk to the sugar mixture, and when well mixt add the boiling 1123 | milk, turn back the mixture into the double boiler, and cook 20 1124 | minutes. Stir constantly until smooth, and occasionally after that. 1125 | Strain all, add more sugar if needed, and when cold add the flavoring. 1126 | Freeze as usual. This may be increased by adding more sugar and cream. 1127 | If the milk is boiled when the cornstarch is added and cooked thoroly 1128 | there will be no taste of cornstarch. Cost, $1.03. Two dozen eggs may 1129 | be added to enrich cream. 1130 | 1131 | 1132 | ### Lemon sherbet (for 40 men). 1133 | 1134 | Take 25 lemons, 6 pounds granulated sugar, 8 quarts boiling water. 1135 | Shave off peel from 12 lemons in thin wafer-like parings, being careful 1136 | to take none of lighter-colored rind below the oil cells. Put parings 1137 | into a bowl and add boiling water and let it stand 10 minutes closely 1138 | covered. Cut the lemons in half, remove the seeds, squeeze out juice 1139 | and add it, with sugar, to the water. If needed, add more sugar. When 1140 | cold strain thru a fine strainer into can and freeze at once. 1141 | 1142 | 1143 | ### Orange sherbet (for 40 men). 1144 | 1145 | Take 8 tablespoonfuls gelatin, 40 oranges or 8 pints orange juice, 7 1146 | pints cold water, 6 pounds granulated sugar, 3 pints boiling water. 1147 | Soak the gelatin in 1 pint cold water. Cut the oranges in halves, 1148 | remove the seeds and squeeze all the juice into a large pitcher or 1149 | bowl. Add sugar to juice. Dissolve the gelatin in the boiling water and 1150 | add all to mixture in pitcher. Strain all into a can and freeze. If 1151 | oranges are very sour use more sugar. 1152 | 1153 | 1154 | ### Apple pie (for 20 men). 1155 | 1156 | Take 2½ pounds stewed apples, season with cinnamon, juice of ½ lemon, 1157 | and skin chopped fine. Crust: 4 pounds flour and 2 pounds lard. 1158 | 1159 | 1160 | ### Pumpkin pie (for 20 men). 1161 | 1162 | Take 2 pumpkins and peel and cut in about 2 or 3-inch squares, cover 1163 | with water and let boil about 1 hour. Drain off water and mash thoroly 1164 | and add ½ pound butter or bacon grease, ¼ pound sugar. Season with 1165 | nutmeg and cinnamon, and 1 ounce salt and 1 quart milk and 4 eggs 1166 | beaten together. Set on stove and let come to a boil, then it is ready. 1167 | Remove and let cool. 1168 | 1169 | 1170 | ### Stewed prunes (for 20 men). 1171 | 1172 | Take 2 pounds prunes, set on stove with water to cover and let cook 2 1173 | hours, or till soft and well done. Flavor with 2 pounds sugar and serve 1174 | cold. 1175 | 1176 | 1177 | 1178 | 1179 | COFFEE. 1180 | 1181 | 1182 | ### Coffee for party. 1183 | 1184 | Take 2 pounds coffee, 5½ gallons water, and whites of 2 eggs. Water 1185 | just boiling. 1186 | 1187 | 1188 | ### Soldier coffee (for 20 men). 1189 | 1190 | Put on stove 2½ gallons water and let come to a boil. Add ½ pound 1191 | ground coffee and let boil about 5 minutes. Remove from stove and put 1192 | in about 1 pint cold water to settle it. It is then ready for use. 1193 | 1194 | 1195 | [Illustration] 1196 | 1197 | 1198 | —————————————————— End of Book —————————————————— 1199 | 1200 | 1201 | Transcriber’s Note (continued) 1202 | 1203 | Page 33 — “3 squares” changed to “3-inch squares” (cut in about 2 or 1204 | 3-inch squares) 1205 | 1206 | 1207 | 1208 | *** END OF THE PROJECT GUTENBERG EBOOK RECIPES USED IN THE COOKING SCHOOLS, U. S. ARMY *** 1209 | 1210 | 1211 | 1212 | 1213 | Updated editions will replace the previous one—the old editions will 1214 | be renamed. 1215 | 1216 | Creating the works from print editions not protected by U.S. copyright 1217 | law means that no one owns a United States copyright in these works, 1218 | so the Foundation (and you!) can copy and distribute it in the United 1219 | States without permission and without paying copyright 1220 | royalties. Special rules, set forth in the General Terms of Use part 1221 | of this license, apply to copying and distributing Project 1222 | Gutenberg™ electronic works to protect the PROJECT GUTENBERG™ 1223 | concept and trademark. Project Gutenberg is a registered trademark, 1224 | and may not be used if you charge for an eBook, except by following 1225 | the terms of the trademark license, including paying royalties for use 1226 | of the Project Gutenberg trademark. If you do not charge anything for 1227 | copies of this eBook, complying with the trademark license is very 1228 | easy. You may use this eBook for nearly any purpose such as creation 1229 | of derivative works, reports, performances and research. Project 1230 | Gutenberg eBooks may be modified and printed and given away—you may 1231 | do practically ANYTHING in the United States with eBooks not protected 1232 | by U.S. copyright law. Redistribution is subject to the trademark 1233 | license, especially commercial redistribution. 1234 | 1235 | 1236 | START: FULL LICENSE 1237 | 1238 | THE FULL PROJECT GUTENBERG LICENSE 1239 | 1240 | PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK 1241 | 1242 | To protect the Project Gutenberg™ mission of promoting the free 1243 | distribution of electronic works, by using or distributing this work 1244 | (or any other work associated in any way with the phrase “Project 1245 | Gutenberg”), you agree to comply with all the terms of the Full 1246 | Project Gutenberg™ License available with this file or online at 1247 | www.gutenberg.org/license. 1248 | 1249 | Section 1. General Terms of Use and Redistributing Project Gutenberg™ 1250 | electronic works 1251 | 1252 | 1.A. By reading or using any part of this Project Gutenberg™ 1253 | electronic work, you indicate that you have read, understand, agree to 1254 | and accept all the terms of this license and intellectual property 1255 | (trademark/copyright) agreement. If you do not agree to abide by all 1256 | the terms of this agreement, you must cease using and return or 1257 | destroy all copies of Project Gutenberg™ electronic works in your 1258 | possession. If you paid a fee for obtaining a copy of or access to a 1259 | Project Gutenberg™ electronic work and you do not agree to be bound 1260 | by the terms of this agreement, you may obtain a refund from the person 1261 | or entity to whom you paid the fee as set forth in paragraph 1.E.8. 1262 | 1263 | 1.B. “Project Gutenberg” is a registered trademark. It may only be 1264 | used on or associated in any way with an electronic work by people who 1265 | agree to be bound by the terms of this agreement. There are a few 1266 | things that you can do with most Project Gutenberg™ electronic works 1267 | even without complying with the full terms of this agreement. See 1268 | paragraph 1.C below. There are a lot of things you can do with Project 1269 | Gutenberg™ electronic works if you follow the terms of this 1270 | agreement and help preserve free future access to Project Gutenberg™ 1271 | electronic works. See paragraph 1.E below. 1272 | 1273 | 1.C. The Project Gutenberg Literary Archive Foundation (“the 1274 | Foundation” or PGLAF), owns a compilation copyright in the collection 1275 | of Project Gutenberg™ electronic works. Nearly all the individual 1276 | works in the collection are in the public domain in the United 1277 | States. If an individual work is unprotected by copyright law in the 1278 | United States and you are located in the United States, we do not 1279 | claim a right to prevent you from copying, distributing, performing, 1280 | displaying or creating derivative works based on the work as long as 1281 | all references to Project Gutenberg are removed. Of course, we hope 1282 | that you will support the Project Gutenberg™ mission of promoting 1283 | free access to electronic works by freely sharing Project Gutenberg™ 1284 | works in compliance with the terms of this agreement for keeping the 1285 | Project Gutenberg™ name associated with the work. You can easily 1286 | comply with the terms of this agreement by keeping this work in the 1287 | same format with its attached full Project Gutenberg™ License when 1288 | you share it without charge with others. 1289 | 1290 | 1.D. The copyright laws of the place where you are located also govern 1291 | what you can do with this work. Copyright laws in most countries are 1292 | in a constant state of change. If you are outside the United States, 1293 | check the laws of your country in addition to the terms of this 1294 | agreement before downloading, copying, displaying, performing, 1295 | distributing or creating derivative works based on this work or any 1296 | other Project Gutenberg™ work. The Foundation makes no 1297 | representations concerning the copyright status of any work in any 1298 | country other than the United States. 1299 | 1300 | 1.E. Unless you have removed all references to Project Gutenberg: 1301 | 1302 | 1.E.1. The following sentence, with active links to, or other 1303 | immediate access to, the full Project Gutenberg™ License must appear 1304 | prominently whenever any copy of a Project Gutenberg™ work (any work 1305 | on which the phrase “Project Gutenberg” appears, or with which the 1306 | phrase “Project Gutenberg” is associated) is accessed, displayed, 1307 | performed, viewed, copied or distributed: 1308 | 1309 | This eBook is for the use of anyone anywhere in the United States and most 1310 | other parts of the world at no cost and with almost no restrictions 1311 | whatsoever. You may copy it, give it away or re-use it under the terms 1312 | of the Project Gutenberg License included with this eBook or online 1313 | at www.gutenberg.org. If you 1314 | are not located in the United States, you will have to check the laws 1315 | of the country where you are located before using this eBook. 1316 | 1317 | 1.E.2. If an individual Project Gutenberg™ electronic work is 1318 | derived from texts not protected by U.S. copyright law (does not 1319 | contain a notice indicating that it is posted with permission of the 1320 | copyright holder), the work can be copied and distributed to anyone in 1321 | the United States without paying any fees or charges. If you are 1322 | redistributing or providing access to a work with the phrase “Project 1323 | Gutenberg” associated with or appearing on the work, you must comply 1324 | either with the requirements of paragraphs 1.E.1 through 1.E.7 or 1325 | obtain permission for the use of the work and the Project Gutenberg™ 1326 | trademark as set forth in paragraphs 1.E.8 or 1.E.9. 1327 | 1328 | 1.E.3. If an individual Project Gutenberg™ electronic work is posted 1329 | with the permission of the copyright holder, your use and distribution 1330 | must comply with both paragraphs 1.E.1 through 1.E.7 and any 1331 | additional terms imposed by the copyright holder. Additional terms 1332 | will be linked to the Project Gutenberg™ License for all works 1333 | posted with the permission of the copyright holder found at the 1334 | beginning of this work. 1335 | 1336 | 1.E.4. Do not unlink or detach or remove the full Project Gutenberg™ 1337 | License terms from this work, or any files containing a part of this 1338 | work or any other work associated with Project Gutenberg™. 1339 | 1340 | 1.E.5. Do not copy, display, perform, distribute or redistribute this 1341 | electronic work, or any part of this electronic work, without 1342 | prominently displaying the sentence set forth in paragraph 1.E.1 with 1343 | active links or immediate access to the full terms of the Project 1344 | Gutenberg™ License. 1345 | 1346 | 1.E.6. You may convert to and distribute this work in any binary, 1347 | compressed, marked up, nonproprietary or proprietary form, including 1348 | any word processing or hypertext form. However, if you provide access 1349 | to or distribute copies of a Project Gutenberg™ work in a format 1350 | other than “Plain Vanilla ASCII” or other format used in the official 1351 | version posted on the official Project Gutenberg™ website 1352 | (www.gutenberg.org), you must, at no additional cost, fee or expense 1353 | to the user, provide a copy, a means of exporting a copy, or a means 1354 | of obtaining a copy upon request, of the work in its original “Plain 1355 | Vanilla ASCII” or other form. Any alternate format must include the 1356 | full Project Gutenberg™ License as specified in paragraph 1.E.1. 1357 | 1358 | 1.E.7. Do not charge a fee for access to, viewing, displaying, 1359 | performing, copying or distributing any Project Gutenberg™ works 1360 | unless you comply with paragraph 1.E.8 or 1.E.9. 1361 | 1362 | 1.E.8. You may charge a reasonable fee for copies of or providing 1363 | access to or distributing Project Gutenberg™ electronic works 1364 | provided that: 1365 | 1366 | • You pay a royalty fee of 20% of the gross profits you derive from 1367 | the use of Project Gutenberg™ works calculated using the method 1368 | you already use to calculate your applicable taxes. The fee is owed 1369 | to the owner of the Project Gutenberg™ trademark, but he has 1370 | agreed to donate royalties under this paragraph to the Project 1371 | Gutenberg Literary Archive Foundation. Royalty payments must be paid 1372 | within 60 days following each date on which you prepare (or are 1373 | legally required to prepare) your periodic tax returns. Royalty 1374 | payments should be clearly marked as such and sent to the Project 1375 | Gutenberg Literary Archive Foundation at the address specified in 1376 | Section 4, “Information about donations to the Project Gutenberg 1377 | Literary Archive Foundation.” 1378 | 1379 | • You provide a full refund of any money paid by a user who notifies 1380 | you in writing (or by e-mail) within 30 days of receipt that s/he 1381 | does not agree to the terms of the full Project Gutenberg™ 1382 | License. You must require such a user to return or destroy all 1383 | copies of the works possessed in a physical medium and discontinue 1384 | all use of and all access to other copies of Project Gutenberg™ 1385 | works. 1386 | 1387 | • You provide, in accordance with paragraph 1.F.3, a full refund of 1388 | any money paid for a work or a replacement copy, if a defect in the 1389 | electronic work is discovered and reported to you within 90 days of 1390 | receipt of the work. 1391 | 1392 | • You comply with all other terms of this agreement for free 1393 | distribution of Project Gutenberg™ works. 1394 | 1395 | 1396 | 1.E.9. If you wish to charge a fee or distribute a Project 1397 | Gutenberg™ electronic work or group of works on different terms than 1398 | are set forth in this agreement, you must obtain permission in writing 1399 | from the Project Gutenberg Literary Archive Foundation, the manager of 1400 | the Project Gutenberg™ trademark. Contact the Foundation as set 1401 | forth in Section 3 below. 1402 | 1403 | 1.F. 1404 | 1405 | 1.F.1. Project Gutenberg volunteers and employees expend considerable 1406 | effort to identify, do copyright research on, transcribe and proofread 1407 | works not protected by U.S. copyright law in creating the Project 1408 | Gutenberg™ collection. Despite these efforts, Project Gutenberg™ 1409 | electronic works, and the medium on which they may be stored, may 1410 | contain “Defects,” such as, but not limited to, incomplete, inaccurate 1411 | or corrupt data, transcription errors, a copyright or other 1412 | intellectual property infringement, a defective or damaged disk or 1413 | other medium, a computer virus, or computer codes that damage or 1414 | cannot be read by your equipment. 1415 | 1416 | 1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the “Right 1417 | of Replacement or Refund” described in paragraph 1.F.3, the Project 1418 | Gutenberg Literary Archive Foundation, the owner of the Project 1419 | Gutenberg™ trademark, and any other party distributing a Project 1420 | Gutenberg™ electronic work under this agreement, disclaim all 1421 | liability to you for damages, costs and expenses, including legal 1422 | fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT 1423 | LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE 1424 | PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE FOUNDATION, THE 1425 | TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE 1426 | LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR 1427 | INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH 1428 | DAMAGE. 1429 | 1430 | 1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a 1431 | defect in this electronic work within 90 days of receiving it, you can 1432 | receive a refund of the money (if any) you paid for it by sending a 1433 | written explanation to the person you received the work from. If you 1434 | received the work on a physical medium, you must return the medium 1435 | with your written explanation. The person or entity that provided you 1436 | with the defective work may elect to provide a replacement copy in 1437 | lieu of a refund. If you received the work electronically, the person 1438 | or entity providing it to you may choose to give you a second 1439 | opportunity to receive the work electronically in lieu of a refund. If 1440 | the second copy is also defective, you may demand a refund in writing 1441 | without further opportunities to fix the problem. 1442 | 1443 | 1.F.4. Except for the limited right of replacement or refund set forth 1444 | in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO 1445 | OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 1446 | LIMITED TO WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE. 1447 | 1448 | 1.F.5. Some states do not allow disclaimers of certain implied 1449 | warranties or the exclusion or limitation of certain types of 1450 | damages. If any disclaimer or limitation set forth in this agreement 1451 | violates the law of the state applicable to this agreement, the 1452 | agreement shall be interpreted to make the maximum disclaimer or 1453 | limitation permitted by the applicable state law. The invalidity or 1454 | unenforceability of any provision of this agreement shall not void the 1455 | remaining provisions. 1456 | 1457 | 1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the 1458 | trademark owner, any agent or employee of the Foundation, anyone 1459 | providing copies of Project Gutenberg™ electronic works in 1460 | accordance with this agreement, and any volunteers associated with the 1461 | production, promotion and distribution of Project Gutenberg™ 1462 | electronic works, harmless from all liability, costs and expenses, 1463 | including legal fees, that arise directly or indirectly from any of 1464 | the following which you do or cause to occur: (a) distribution of this 1465 | or any Project Gutenberg™ work, (b) alteration, modification, or 1466 | additions or deletions to any Project Gutenberg™ work, and (c) any 1467 | Defect you cause. 1468 | 1469 | Section 2. Information about the Mission of Project Gutenberg™ 1470 | 1471 | Project Gutenberg™ is synonymous with the free distribution of 1472 | electronic works in formats readable by the widest variety of 1473 | computers including obsolete, old, middle-aged and new computers. It 1474 | exists because of the efforts of hundreds of volunteers and donations 1475 | from people in all walks of life. 1476 | 1477 | Volunteers and financial support to provide volunteers with the 1478 | assistance they need are critical to reaching Project Gutenberg™’s 1479 | goals and ensuring that the Project Gutenberg™ collection will 1480 | remain freely available for generations to come. In 2001, the Project 1481 | Gutenberg Literary Archive Foundation was created to provide a secure 1482 | and permanent future for Project Gutenberg™ and future 1483 | generations. To learn more about the Project Gutenberg Literary 1484 | Archive Foundation and how your efforts and donations can help, see 1485 | Sections 3 and 4 and the Foundation information page at www.gutenberg.org. 1486 | 1487 | Section 3. Information about the Project Gutenberg Literary Archive Foundation 1488 | 1489 | The Project Gutenberg Literary Archive Foundation is a non-profit 1490 | 501(c)(3) educational corporation organized under the laws of the 1491 | state of Mississippi and granted tax exempt status by the Internal 1492 | Revenue Service. The Foundation’s EIN or federal tax identification 1493 | number is 64-6221541. Contributions to the Project Gutenberg Literary 1494 | Archive Foundation are tax deductible to the full extent permitted by 1495 | U.S. federal laws and your state’s laws. 1496 | 1497 | The Foundation’s business office is located at 809 North 1500 West, 1498 | Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up 1499 | to date contact information can be found at the Foundation’s website 1500 | and official page at www.gutenberg.org/contact 1501 | 1502 | Section 4. Information about Donations to the Project Gutenberg 1503 | Literary Archive Foundation 1504 | 1505 | Project Gutenberg™ depends upon and cannot survive without widespread 1506 | public support and donations to carry out its mission of 1507 | increasing the number of public domain and licensed works that can be 1508 | freely distributed in machine-readable form accessible by the widest 1509 | array of equipment including outdated equipment. Many small donations 1510 | ($1 to $5,000) are particularly important to maintaining tax exempt 1511 | status with the IRS. 1512 | 1513 | The Foundation is committed to complying with the laws regulating 1514 | charities and charitable donations in all 50 states of the United 1515 | States. Compliance requirements are not uniform and it takes a 1516 | considerable effort, much paperwork and many fees to meet and keep up 1517 | with these requirements. We do not solicit donations in locations 1518 | where we have not received written confirmation of compliance. To SEND 1519 | DONATIONS or determine the status of compliance for any particular state 1520 | visit www.gutenberg.org/donate. 1521 | 1522 | While we cannot and do not solicit contributions from states where we 1523 | have not met the solicitation requirements, we know of no prohibition 1524 | against accepting unsolicited donations from donors in such states who 1525 | approach us with offers to donate. 1526 | 1527 | International donations are gratefully accepted, but we cannot make 1528 | any statements concerning tax treatment of donations received from 1529 | outside the United States. U.S. laws alone swamp our small staff. 1530 | 1531 | Please check the Project Gutenberg web pages for current donation 1532 | methods and addresses. Donations are accepted in a number of other 1533 | ways including checks, online payments and credit card donations. To 1534 | donate, please visit: www.gutenberg.org/donate. 1535 | 1536 | Section 5. General Information About Project Gutenberg™ electronic works 1537 | 1538 | Professor Michael S. Hart was the originator of the Project 1539 | Gutenberg™ concept of a library of electronic works that could be 1540 | freely shared with anyone. For forty years, he produced and 1541 | distributed Project Gutenberg™ eBooks with only a loose network of 1542 | volunteer support. 1543 | 1544 | Project Gutenberg™ eBooks are often created from several printed 1545 | editions, all of which are confirmed as not protected by copyright in 1546 | the U.S. unless a copyright notice is included. Thus, we do not 1547 | necessarily keep eBooks in compliance with any particular paper 1548 | edition. 1549 | 1550 | Most people start at our website which has the main PG search 1551 | facility: www.gutenberg.org. 1552 | 1553 | This website includes information about Project Gutenberg™, 1554 | including how to make donations to the Project Gutenberg Literary 1555 | Archive Foundation, how to help produce our new eBooks, and how to 1556 | subscribe to our email newsletter to hear about new eBooks. 1557 | 1558 | 1559 | -------------------------------------------------------------------------------- /filter.py: -------------------------------------------------------------------------------- 1 | from langchain.retrievers.document_compressors import DocumentCompressorPipeline 2 | from langchain_community.document_transformers import EmbeddingsRedundantFilter, LongContextReorder 3 | from langchain_community.embeddings import HuggingFaceBgeEmbeddings, HuggingFaceEmbeddings 4 | from langchain_community.retrievers import BM25Retriever 5 | from langchain.retrievers import EnsembleRetriever, ContextualCompressionRetriever, MergerRetriever 6 | from langchain.chains import RetrievalQA 7 | 8 | from basic_chain import get_model 9 | from remote_loader import load_web_page 10 | from splitter import split_documents 11 | from vector_store import create_vector_db 12 | 13 | from dotenv import load_dotenv 14 | 15 | 16 | def create_retriever(texts): 17 | dense_embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2") 18 | sparse_embeddings = HuggingFaceBgeEmbeddings(model_name="BAAI/bge-large-en", 19 | encode_kwargs={'normalize_embeddings': False}) 20 | dense_vs = create_vector_db(texts, collection_name="dense", embeddings=dense_embeddings) 21 | sparse_vs = create_vector_db(texts, collection_name="sparse", embeddings=sparse_embeddings) 22 | vector_stores = [dense_vs, sparse_vs] 23 | 24 | emb_filter = EmbeddingsRedundantFilter(embeddings=sparse_embeddings) 25 | reordering = LongContextReorder() 26 | pipeline = DocumentCompressorPipeline(transformers=[emb_filter, reordering]) 27 | 28 | base_retrievers = [vs.as_retriever() for vs in vector_stores] 29 | lotr = MergerRetriever(retrievers=base_retrievers) 30 | 31 | compression_retriever_reordered = ContextualCompressionRetriever( 32 | base_compressor=pipeline, base_retriever=lotr, search_kwargs={"k": 5, "include_metadata": True} 33 | ) 34 | return compression_retriever_reordered 35 | 36 | 37 | def ensemble_retriever_from_docs(docs): 38 | texts = split_documents(docs) 39 | vs_retriever = create_retriever(texts) 40 | 41 | bm25_retriever = BM25Retriever.from_texts([t.page_content for t in texts]) 42 | 43 | ensemble_retriever = EnsembleRetriever( 44 | retrievers=[bm25_retriever, vs_retriever], weights=[0.5, 0.5]) 45 | 46 | return ensemble_retriever 47 | 48 | 49 | def main(): 50 | load_dotenv() 51 | 52 | problems_of_philosophy_by_russell = "https://www.gutenberg.org/ebooks/5827.html.images" 53 | 54 | docs = load_web_page(problems_of_philosophy_by_russell) 55 | ensemble_retriever = ensemble_retriever_from_docs(docs) 56 | llm = get_model() 57 | qa = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=ensemble_retriever) 58 | 59 | results = qa.invoke("What are the key problems of philosophy according to Russell?") 60 | print(results) 61 | 62 | 63 | if __name__ == "__main__": 64 | main() 65 | -------------------------------------------------------------------------------- /full_chain.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from dotenv import load_dotenv 4 | from langchain.memory import ChatMessageHistory 5 | from langchain_core.prompts import ChatPromptTemplate 6 | 7 | from basic_chain import get_model 8 | from filter import ensemble_retriever_from_docs 9 | from local_loader import load_txt_files 10 | from memory import create_memory_chain 11 | from rag_chain import make_rag_chain 12 | 13 | 14 | def create_full_chain(retriever, openai_api_key=None, chat_memory=ChatMessageHistory()): 15 | model = get_model("ChatGPT", openai_api_key=openai_api_key) 16 | system_prompt = """You are a helpful AI assistant for busy professionals trying to improve their health. 17 | Use the following context and the users' chat history to help the user: 18 | If you don't know the answer, just say that you don't know. 19 | 20 | Context: {context} 21 | 22 | Question: """ 23 | 24 | prompt = ChatPromptTemplate.from_messages( 25 | [ 26 | ("system", system_prompt), 27 | ("human", "{question}"), 28 | ] 29 | ) 30 | 31 | rag_chain = make_rag_chain(model, retriever, rag_prompt=prompt) 32 | chain = create_memory_chain(model, rag_chain, chat_memory) 33 | return chain 34 | 35 | 36 | def ask_question(chain, query): 37 | response = chain.invoke( 38 | {"question": query}, 39 | config={"configurable": {"session_id": "foo"}} 40 | ) 41 | return response 42 | 43 | 44 | def main(): 45 | load_dotenv() 46 | 47 | from rich.console import Console 48 | from rich.markdown import Markdown 49 | console = Console() 50 | 51 | docs = load_txt_files() 52 | ensemble_retriever = ensemble_retriever_from_docs(docs) 53 | chain = create_full_chain(ensemble_retriever) 54 | 55 | queries = [ 56 | "Generate a grocery list for my family meal plan for the next week(following 7 days). Prefer local, in-season ingredients." 57 | "Create a list of estimated calorie counts and grams of carbohydrates for each meal." 58 | ] 59 | 60 | for query in queries: 61 | response = ask_question(chain, query) 62 | console.print(Markdown(response.content)) 63 | 64 | 65 | if __name__ == '__main__': 66 | # this is to quiet parallel tokenizers warning. 67 | os.environ["TOKENIZERS_PARALLELISM"] = "false" 68 | main() 69 | -------------------------------------------------------------------------------- /local_loader.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pathlib import Path 3 | 4 | from pypdf import PdfReader 5 | from langchain.docstore.document import Document 6 | from langchain_community.document_loaders import TextLoader 7 | from langchain_community.document_loaders.csv_loader import CSVLoader 8 | 9 | 10 | def list_txt_files(data_dir="./data"): 11 | paths = Path(data_dir).glob('**/*.txt') 12 | for path in paths: 13 | yield str(path) 14 | 15 | 16 | def load_txt_files(data_dir="./data"): 17 | docs = [] 18 | paths = list_txt_files(data_dir) 19 | for path in paths: 20 | print(f"Loading {path}") 21 | loader = TextLoader(path) 22 | docs.extend(loader.load()) 23 | return docs 24 | 25 | 26 | def load_csv_files(data_dir="./data"): 27 | docs = [] 28 | paths = Path(data_dir).glob('**/*.csv') 29 | for path in paths: 30 | loader = CSVLoader(file_path=str(path)) 31 | docs.extend(loader.load()) 32 | return docs 33 | 34 | 35 | # Use with result of file_to_summarize = st.file_uploader("Choose a file") or a string. 36 | # or a file like object. 37 | def get_document_text(uploaded_file, title=None): 38 | docs = [] 39 | fname = uploaded_file.name 40 | if not title: 41 | title = os.path.basename(fname) 42 | if fname.lower().endswith('pdf'): 43 | pdf_reader = PdfReader(uploaded_file) 44 | for num, page in enumerate(pdf_reader.pages): 45 | page = page.extract_text() 46 | doc = Document(page_content=page, metadata={'title': title, 'page': (num + 1)}) 47 | docs.append(doc) 48 | 49 | else: 50 | # assume text 51 | doc_text = uploaded_file.read().decode() 52 | docs.append(doc_text) 53 | 54 | return docs 55 | 56 | 57 | if __name__ == "__main__": 58 | example_pdf_path = "examples/healthy_meal_10_tips.pdf" 59 | docs = get_document_text(open(example_pdf_path, "rb")) 60 | for doc in docs: 61 | print(doc) 62 | docs = get_document_text(open("examples/us_army_recipes.txt", "rb")) 63 | for doc in docs: 64 | print(doc) 65 | txt_docs = load_txt_files("examples") 66 | for doc in txt_docs: 67 | print(doc) 68 | csv_docs = load_csv_files("examples") 69 | for doc in csv_docs: 70 | print(doc) 71 | 72 | -------------------------------------------------------------------------------- /memory.py: -------------------------------------------------------------------------------- 1 | import os 2 | from typing import List, Iterable, Any 3 | 4 | from dotenv import load_dotenv 5 | from langchain.memory import ChatMessageHistory 6 | from langchain_core.callbacks import CallbackManagerForRetrieverRun 7 | from langchain_core.chat_history import BaseChatMessageHistory 8 | from langchain_core.documents import Document 9 | from langchain_core.output_parsers import StrOutputParser 10 | from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder 11 | from langchain_core.retrievers import BaseRetriever 12 | from langchain_core.runnables.history import RunnableWithMessageHistory 13 | 14 | from basic_chain import get_model 15 | from rag_chain import make_rag_chain 16 | 17 | 18 | def create_memory_chain(llm, base_chain, chat_memory): 19 | contextualize_q_system_prompt = """Given a chat history and the latest user question \ 20 | which might reference context in the chat history, formulate a standalone question \ 21 | which can be understood without the chat history. Do NOT answer the question, \ 22 | just reformulate it if needed and otherwise return it as is.""" 23 | 24 | contextualize_q_prompt = ChatPromptTemplate.from_messages( 25 | [ 26 | ("system", contextualize_q_system_prompt), 27 | MessagesPlaceholder(variable_name="chat_history"), 28 | ("human", "{question}"), 29 | ] 30 | ) 31 | 32 | runnable = contextualize_q_prompt | llm | base_chain 33 | 34 | def get_session_history(session_id: str) -> BaseChatMessageHistory: 35 | return chat_memory 36 | 37 | with_message_history = RunnableWithMessageHistory( 38 | runnable, 39 | get_session_history, 40 | input_messages_key="question", 41 | history_messages_key="chat_history", 42 | ) 43 | return with_message_history 44 | 45 | 46 | class SimpleTextRetriever(BaseRetriever): 47 | docs: List[Document] 48 | """Documents.""" 49 | 50 | @classmethod 51 | def from_texts( 52 | cls, 53 | texts: Iterable[str], 54 | **kwargs: Any, 55 | ): 56 | docs = [Document(page_content=t) for t in texts] 57 | return cls(docs=docs, **kwargs) 58 | 59 | def _get_relevant_documents( 60 | self, query: str, *, run_manager: CallbackManagerForRetrieverRun 61 | ) -> List[Document]: 62 | return self.docs 63 | 64 | 65 | def main(): 66 | load_dotenv() 67 | model = get_model("ChatGPT") 68 | chat_memory = ChatMessageHistory() 69 | 70 | system_prompt = "You are a helpful AI assistant for busy professionals trying to improve their health." 71 | prompt = ChatPromptTemplate.from_messages( 72 | [ 73 | ("system", system_prompt), 74 | MessagesPlaceholder(variable_name="chat_history"), 75 | ("human", "{question}"), 76 | ] 77 | ) 78 | 79 | text_path = "examples/grocery.md" 80 | text = open(text_path, "r").read() 81 | retriever = SimpleTextRetriever.from_texts([text]) 82 | rag_chain = make_rag_chain(model, retriever, rag_prompt=None) 83 | chain = create_memory_chain(model, rag_chain, chat_memory) | StrOutputParser() 84 | queries = [ 85 | "What do I need to get from the grocery store besides milk?", 86 | "Which of these items can I find at a farmer's market?", 87 | ] 88 | 89 | for query in queries: 90 | print(f"\nQuestion: {query}") 91 | response = chain.invoke( 92 | {"question": query}, 93 | config={"configurable": {"session_id": "foo"}} 94 | ) 95 | print(f"Answer: {response}") 96 | 97 | 98 | if __name__ == "__main__": 99 | # this is to quite parallel tokenizers warning. 100 | os.environ["TOKENIZERS_PARALLELISM"] = "false" 101 | main() 102 | -------------------------------------------------------------------------------- /packages.txt: -------------------------------------------------------------------------------- 1 | libblas-dev 2 | liblapack-dev 3 | -------------------------------------------------------------------------------- /rag_chain.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from dotenv import load_dotenv 4 | from langchain import hub 5 | from langchain_core.output_parsers import StrOutputParser 6 | from langchain_core.prompts import ChatPromptTemplate 7 | from langchain_core.runnables import RunnablePassthrough, RunnableLambda 8 | from langchain_core.messages.base import BaseMessage 9 | 10 | from basic_chain import basic_chain, get_model 11 | from remote_loader import get_wiki_docs 12 | from splitter import split_documents 13 | from vector_store import create_vector_db 14 | 15 | 16 | def find_similar(vs, query): 17 | docs = vs.similarity_search(query) 18 | return docs 19 | 20 | 21 | def format_docs(docs): 22 | return "\n\n".join(doc.page_content for doc in docs) 23 | 24 | 25 | def get_question(input): 26 | if not input: 27 | return None 28 | elif isinstance(input,str): 29 | return input 30 | elif isinstance(input,dict) and 'question' in input: 31 | return input['question'] 32 | elif isinstance(input,BaseMessage): 33 | return input.content 34 | else: 35 | raise Exception("string or dict with 'question' key expected as RAG chain input.") 36 | 37 | 38 | def make_rag_chain(model, retriever, rag_prompt = None): 39 | # We will use a prompt template from langchain hub. 40 | if not rag_prompt: 41 | rag_prompt = hub.pull("rlm/rag-prompt") 42 | 43 | # And we will use the LangChain RunnablePassthrough to add some custom processing into our chain. 44 | rag_chain = ( 45 | { 46 | "context": RunnableLambda(get_question) | retriever | format_docs, 47 | "question": RunnablePassthrough() 48 | } 49 | | rag_prompt 50 | | model 51 | ) 52 | 53 | return rag_chain 54 | 55 | 56 | def main(): 57 | load_dotenv() 58 | model = get_model("ChatGPT") 59 | docs = get_wiki_docs(query="Bertrand Russell", load_max_docs=5) 60 | texts = split_documents(docs) 61 | vs = create_vector_db(texts) 62 | 63 | prompt = ChatPromptTemplate.from_messages([ 64 | ("system", "You are a professor who teaches philosophical concepts to beginners."), 65 | ("user", "{input}") 66 | ]) 67 | # Besides similarly search, you can also use maximal marginal relevance (MMR) for selecting results. 68 | # retriever = vs.as_retriever(search_type="mmr") 69 | retriever = vs.as_retriever() 70 | 71 | output_parser = StrOutputParser() 72 | chain = basic_chain(model, prompt) 73 | base_chain = chain | output_parser 74 | rag_chain = make_rag_chain(model, retriever) | output_parser 75 | 76 | questions = [ 77 | "What were the most important contributions of Bertrand Russell to philosophy?", 78 | "What was the first book Bertrand Russell published?", 79 | "What was most notable about \"An Essay on the Foundations of Geometry\"?", 80 | ] 81 | for q in questions: 82 | print("\n--- QUESTION: ", q) 83 | print("* BASE:\n", base_chain.invoke({"input": q})) 84 | print("* RAG:\n", rag_chain.invoke(q)) 85 | 86 | 87 | if __name__ == '__main__': 88 | # this is to quite parallel tokenizers warning. 89 | os.environ["TOKENIZERS_PARALLELISM"] = "false" 90 | main() 91 | -------------------------------------------------------------------------------- /remote_loader.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import os 3 | 4 | from langchain_community.document_loaders import WebBaseLoader, WikipediaLoader 5 | from local_loader import get_document_text 6 | from langchain_community.document_loaders import OnlinePDFLoader 7 | 8 | 9 | # if you want it locally, you can use: 10 | CONTENT_DIR = os.path.dirname(__file__) 11 | 12 | 13 | # an alternative if you want it in /tmp or equivalent. 14 | # CONTENT_DIR = tempfile.gettempdir() 15 | 16 | def load_web_page(page_url): 17 | loader = WebBaseLoader(page_url) 18 | data = loader.load() 19 | return data 20 | 21 | 22 | def load_online_pdf(pdf_url): 23 | loader = OnlinePDFLoader(pdf_url) 24 | data = loader.load() 25 | return data 26 | 27 | 28 | def filename_from_url(url): 29 | filename = url.split("/")[-1] 30 | return filename 31 | 32 | 33 | def download_file(url, filename=None): 34 | response = requests.get(url) 35 | if not filename: 36 | filename = filename_from_url(url) 37 | 38 | full_path = os.path.join(CONTENT_DIR, filename) 39 | 40 | with open(full_path, mode="wb") as f: 41 | f.write(response.content) 42 | download_path = os.path.realpath(f.name) 43 | print(f"Downloaded file {filename} to {download_path}") 44 | return download_path 45 | 46 | 47 | def get_wiki_docs(query, load_max_docs=2): 48 | wiki_loader = WikipediaLoader(query=query, load_max_docs=load_max_docs) 49 | docs = wiki_loader.load() 50 | for d in docs: 51 | print(d.metadata["title"]) 52 | return docs 53 | 54 | 55 | def main(): 56 | # run through the different remote loading functions. 57 | problems_of_philosophy_by_russell = "https://www.gutenberg.org/ebooks/5827.html.images" 58 | docs = load_web_page(problems_of_philosophy_by_russell) 59 | for doc in docs: 60 | print(doc) 61 | 62 | math_analysis_of_logic_by_boole = "https://www.gutenberg.org/files/36884/36884-pdf.pdf" 63 | local_pdf_path = download_file(math_analysis_of_logic_by_boole) 64 | 65 | with open(local_pdf_path, "rb") as pdf_file: 66 | docs = get_document_text(pdf_file, title="Analysis of Logic") 67 | 68 | for doc in docs: 69 | print(doc) 70 | 71 | problems_of_philosophy_pdf = "https://s3-us-west-2.amazonaws.com/pressbooks-samplefiles/LewisTheme/The-Problems-of-Philosophy-LewisTheme.pdf" 72 | docs = load_online_pdf(problems_of_philosophy_pdf) 73 | for doc in docs: 74 | print(doc) 75 | 76 | 77 | if __name__ == "__main__": 78 | main() 79 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | chroma-hnswlib==0.7.3 2 | chromadb==0.3.29 3 | huggingface-hub==0.21.3 4 | langchain==0.1.9 5 | langchain-community==0.0.24 6 | langchain-core==0.1.35 7 | langchain-openai==0.0.8 8 | langchain-text-splitters==0.0.1 9 | langchainhub==0.1.14 10 | langdetect==1.0.9 11 | langsmith==0.1.26 12 | numpy==1.26.4 13 | openai==1.13.3 14 | opencv-python==4.9.0.80 15 | pandas==2.2.1 16 | pdf2image==1.17.0 17 | pdfminer.six==20221105 18 | pdfplumber==0.10.4 19 | pikepdf==8.13.0 20 | pillow==10.2.0 21 | pillow_heif==0.15.0 22 | pyarrow==15.0.0 23 | pydantic==1.10.14 24 | pypdf==4.0.2 25 | pypdfium2==4.27.0 26 | pytesseract==0.3.10 27 | python-dotenv 28 | PyYAML 29 | rank-bm25 30 | regex 31 | requests 32 | rich 33 | safetensors==0.4.2 34 | scikit-learn==1.4.1.post1 35 | scipy==1.12.0 36 | sentence-transformers==2.4.0 37 | SQLAlchemy==2.0.27 38 | streamlit==1.31.1 39 | sympy==1.12 40 | tiktoken==0.5.2 41 | tokenizers==0.15.2 42 | toml 43 | torch==2.2.1 44 | torchvision==0.17.1 45 | tqdm 46 | transformers==4.38.2 47 | unstructured==0.12.4 48 | unstructured-client==0.18.0 49 | unstructured-inference==0.7.23 50 | unstructured.pytesseract==0.3.12 51 | watchdog 52 | watchfiles 53 | wikipedia 54 | -------------------------------------------------------------------------------- /run_all_mains.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | FILES_WITH_MAIN=`grep -l main *.py` 6 | for F in $FILES_WITH_MAIN; do 7 | echo "Running $F" 8 | python $F 9 | echo 10 | done 11 | -------------------------------------------------------------------------------- /splitter.py: -------------------------------------------------------------------------------- 1 | # Split documents into chunks 2 | from langchain.text_splitter import RecursiveCharacterTextSplitter 3 | from langchain.docstore.document import Document 4 | 5 | def split_documents(docs): 6 | text_splitter = RecursiveCharacterTextSplitter( 7 | chunk_size=1000, 8 | chunk_overlap=0, 9 | length_function=len, 10 | is_separator_regex=False) 11 | 12 | contents = docs 13 | if docs and isinstance(docs[0], Document): 14 | contents = [doc.page_content for doc in docs] 15 | 16 | texts = text_splitter.create_documents(contents) 17 | n_chunks = len(texts) 18 | print(f"Split into {n_chunks} chunks") 19 | return texts 20 | 21 | -------------------------------------------------------------------------------- /streamlit_app.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | from langchain_community.chat_message_histories import StreamlitChatMessageHistory 3 | from langchain_community.embeddings import OpenAIEmbeddings 4 | 5 | from ensemble import ensemble_retriever_from_docs 6 | from full_chain import create_full_chain, ask_question 7 | from local_loader import load_txt_files 8 | 9 | st.set_page_config(page_title="LangChain & Streamlit RAG") 10 | st.title("LangChain & Streamlit RAG") 11 | 12 | 13 | def show_ui(qa, prompt_to_user="How may I help you?"): 14 | if "messages" not in st.session_state.keys(): 15 | st.session_state.messages = [{"role": "assistant", "content": prompt_to_user}] 16 | 17 | # Display chat messages 18 | for message in st.session_state.messages: 19 | with st.chat_message(message["role"]): 20 | st.write(message["content"]) 21 | 22 | # User-provided prompt 23 | if prompt := st.chat_input(): 24 | st.session_state.messages.append({"role": "user", "content": prompt}) 25 | with st.chat_message("user"): 26 | st.write(prompt) 27 | 28 | # Generate a new response if last message is not from assistant 29 | if st.session_state.messages[-1]["role"] != "assistant": 30 | with st.chat_message("assistant"): 31 | with st.spinner("Thinking..."): 32 | response = ask_question(qa, prompt) 33 | st.markdown(response.content) 34 | message = {"role": "assistant", "content": response.content} 35 | st.session_state.messages.append(message) 36 | 37 | 38 | @st.cache_resource 39 | def get_retriever(openai_api_key=None): 40 | docs = load_txt_files() 41 | embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key, model="text-embedding-3-small") 42 | return ensemble_retriever_from_docs(docs, embeddings=embeddings) 43 | 44 | 45 | def get_chain(openai_api_key=None, huggingfacehub_api_token=None): 46 | ensemble_retriever = get_retriever(openai_api_key=openai_api_key) 47 | chain = create_full_chain(ensemble_retriever, 48 | openai_api_key=openai_api_key, 49 | chat_memory=StreamlitChatMessageHistory(key="langchain_messages")) 50 | return chain 51 | 52 | 53 | def get_secret_or_input(secret_key, secret_name, info_link=None): 54 | if secret_key in st.secrets: 55 | st.write("Found %s secret" % secret_key) 56 | secret_value = st.secrets[secret_key] 57 | else: 58 | st.write(f"Please provide your {secret_name}") 59 | secret_value = st.text_input(secret_name, key=f"input_{secret_key}", type="password") 60 | if secret_value: 61 | st.session_state[secret_key] = secret_value 62 | if info_link: 63 | st.markdown(f"[Get an {secret_name}]({info_link})") 64 | return secret_value 65 | 66 | 67 | def run(): 68 | ready = True 69 | 70 | openai_api_key = st.session_state.get("OPENAI_API_KEY") 71 | huggingfacehub_api_token = st.session_state.get("HUGGINGFACEHUB_API_TOKEN") 72 | 73 | with st.sidebar: 74 | if not openai_api_key: 75 | openai_api_key = get_secret_or_input('OPENAI_API_KEY', "OpenAI API key", 76 | info_link="https://platform.openai.com/account/api-keys") 77 | if not huggingfacehub_api_token: 78 | huggingfacehub_api_token = get_secret_or_input('HUGGINGFACEHUB_API_TOKEN', "HuggingFace Hub API Token", 79 | info_link="https://huggingface.co/docs/huggingface_hub/main/en/quick-start#authentication") 80 | 81 | if not openai_api_key: 82 | st.warning("Missing OPENAI_API_KEY") 83 | ready = False 84 | if not huggingfacehub_api_token: 85 | st.warning("Missing HUGGINGFACEHUB_API_TOKEN") 86 | ready = False 87 | 88 | if ready: 89 | chain = get_chain(openai_api_key=openai_api_key, huggingfacehub_api_token=huggingfacehub_api_token) 90 | st.subheader("Ask me questions about this week's meal plan") 91 | show_ui(chain, "What would you like to know?") 92 | else: 93 | st.stop() 94 | 95 | 96 | run() 97 | -------------------------------------------------------------------------------- /vector_store.py: -------------------------------------------------------------------------------- 1 | import os 2 | from typing import List 3 | 4 | from langchain_openai import OpenAIEmbeddings 5 | from langchain_community.vectorstores import Chroma 6 | from local_loader import get_document_text 7 | from remote_loader import download_file 8 | from splitter import split_documents 9 | from dotenv import load_dotenv 10 | from time import sleep 11 | 12 | EMBED_DELAY = 0.02 # 20 milliseconds 13 | 14 | # This is to get the Streamlit app to use less CPU while embedding documents into Chromadb. 15 | class EmbeddingProxy: 16 | def __init__(self, embedding): 17 | self.embedding = embedding 18 | 19 | def embed_documents(self, texts: List[str]) -> List[List[float]]: 20 | sleep(EMBED_DELAY) 21 | return self.embedding.embed_documents(texts) 22 | 23 | def embed_query(self, text: str) -> List[float]: 24 | sleep(EMBED_DELAY) 25 | return self.embedding.embed_query(text) 26 | 27 | 28 | # This happens all at once, not ideal for large datasets. 29 | def create_vector_db(texts, embeddings=None, collection_name="chroma"): 30 | # Select embeddings 31 | if not embeddings: 32 | # To use HuggingFace embeddings instead: 33 | # from langchain_community.embeddings import HuggingFaceEmbeddings 34 | # embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2") 35 | openai_api_key = os.environ["OPENAI_API_KEY"] 36 | embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key, model="text-embedding-3-small") 37 | 38 | proxy_embeddings = EmbeddingProxy(embeddings) 39 | # Create a vectorstore from documents 40 | # this will be a chroma collection with a default name. 41 | db = Chroma(collection_name=collection_name, 42 | embedding_function=proxy_embeddings, 43 | persist_directory=os.path.join("store/", collection_name)) 44 | db.add_documents(texts) 45 | 46 | # db = Chroma.from_documents(texts, embeddings) 47 | return db 48 | 49 | 50 | def find_similar(vs, query): 51 | docs = vs.similarity_search(query) 52 | return docs 53 | 54 | 55 | def main(): 56 | load_dotenv() 57 | 58 | pdf_filename = "examples/mal_boole.pdf" 59 | 60 | if not os.path.exists(pdf_filename): 61 | math_analysis_of_logic_by_boole = "https://www.gutenberg.org/files/36884/36884-pdf.pdf" 62 | local_pdf_path = download_file(math_analysis_of_logic_by_boole, pdf_filename) 63 | else: 64 | local_pdf_path = pdf_filename 65 | 66 | print(f"PDF path is {local_pdf_path}") 67 | 68 | with open(local_pdf_path, "rb") as pdf_file: 69 | docs = get_document_text(pdf_file, title="Analysis of Logic") 70 | 71 | texts = split_documents(docs) 72 | vs = create_vector_db(texts) 73 | 74 | results = find_similar(vs, query="What is meant by the simple conversion of a proposition?") 75 | MAX_CHARS = 300 76 | print("=== Results ===") 77 | for i, text in enumerate(results): 78 | # cap to max length but split by words. 79 | content = text.page_content 80 | n = max(content.find(' ', MAX_CHARS), MAX_CHARS) 81 | content = text.page_content[:n] 82 | print(f"Result {i + 1}:\n {content}\n") 83 | 84 | 85 | if __name__ == "__main__": 86 | main() 87 | --------------------------------------------------------------------------------