|
16 | 16 | }, |
17 | 17 | { |
18 | 18 | "cell_type": "code", |
19 | | - "execution_count": 11, |
| 19 | + "execution_count": null, |
20 | 20 | "metadata": {}, |
21 | 21 | "outputs": [], |
22 | 22 | "source": [ |
23 | | - "# Import needed modules from LightRAG\n", |
24 | | - "from adalflow.core.component import Component\n", |
| 23 | + "# Import needed modules from LightRAGfrom adalflow.core.component import Component\n", |
25 | 24 | "from adalflow.core.generator import Generator\n", |
26 | | - "from adalflow.core.memory import Memory" |
| 25 | + "from adalflow.components.memory.memory import Memory" |
27 | 26 | ] |
28 | 27 | }, |
29 | 28 | { |
30 | 29 | "cell_type": "code", |
31 | | - "execution_count": 12, |
| 30 | + "execution_count": null, |
32 | 31 | "metadata": {}, |
33 | 32 | "outputs": [], |
34 | 33 | "source": [ |
|
39 | 38 | }, |
40 | 39 | { |
41 | 40 | "cell_type": "code", |
42 | | - "execution_count": 14, |
| 41 | + "execution_count": null, |
43 | 42 | "metadata": {}, |
44 | | - "outputs": [ |
45 | | - { |
46 | | - "name": "stdout", |
47 | | - "output_type": "stream", |
48 | | - "text": [ |
49 | | - "ChatBot(\n", |
50 | | - " (generator): Generator(\n", |
51 | | - " model_kwargs={'model': 'gpt-3.5-turbo'}, model_type=ModelType.LLM\n", |
52 | | - " (system_prompt): Prompt(\n", |
53 | | - " template: {# task desc #}\n", |
54 | | - " {% if task_desc_str %}\n", |
55 | | - " {{task_desc_str}}\n", |
56 | | - " {% else %}\n", |
57 | | - " Answer user query.\n", |
58 | | - " {% endif %}\n", |
59 | | - " {# output format #}\n", |
60 | | - " {% if output_format_str %}\n", |
61 | | - " <OUTPUT_FORMAT>\n", |
62 | | - " {{output_format_str}}\n", |
63 | | - " </OUTPUT_FORMAT>\n", |
64 | | - " {% endif %}\n", |
65 | | - " {# tools #}\n", |
66 | | - " {% if tools_str %}\n", |
67 | | - " <TOOLS>\n", |
68 | | - " {{tools_str}}\n", |
69 | | - " </TOOLS>\n", |
70 | | - " {% endif %}\n", |
71 | | - " {# example #}\n", |
72 | | - " {% if examples_str %}\n", |
73 | | - " <EXAMPLES>\n", |
74 | | - " {{examples_str}}\n", |
75 | | - " </EXAMPLES>\n", |
76 | | - " {% endif %}\n", |
77 | | - " {# chat history #}\n", |
78 | | - " {% if chat_history_str %}\n", |
79 | | - " <CHAT_HISTORY>\n", |
80 | | - " {{chat_history_str}}\n", |
81 | | - " </CHAT_HISTORY>\n", |
82 | | - " {% endif %}\n", |
83 | | - " {#contex#}\n", |
84 | | - " {% if context_str %}\n", |
85 | | - " <CONTEXT>\n", |
86 | | - " {{context_str}}\n", |
87 | | - " </CONTEXT>\n", |
88 | | - " {% endif %}\n", |
89 | | - " {# steps #}\n", |
90 | | - " {% if steps_str %}\n", |
91 | | - " <STEPS>\n", |
92 | | - " {{steps_str}}\n", |
93 | | - " </STEPS>\n", |
94 | | - " {% endif %}\n", |
95 | | - " {% if input_str %}\n", |
96 | | - " <Inputs>\n", |
97 | | - " {{input_str}}\n", |
98 | | - " </Inputs>\n", |
99 | | - " {% endif %}\n", |
100 | | - " {% if output_str %}\n", |
101 | | - " <Outputs>\n", |
102 | | - " {{output_str}}\n", |
103 | | - " </Outputs>\n", |
104 | | - " {% endif %}\n", |
105 | | - " , prompt_variables: ['context_str', 'task_desc_str', 'tools_str', 'chat_history_str', 'input_str', 'output_str', 'output_format_str', 'steps_str', 'examples_str']\n", |
106 | | - " )\n", |
107 | | - " (model_client): OpenAIClient()\n", |
108 | | - " )\n", |
109 | | - " (chat_history): Memory()\n", |
110 | | - ")\n" |
111 | | - ] |
112 | | - } |
113 | | - ], |
| 43 | + "outputs": [], |
114 | 44 | "source": [ |
115 | 45 | "# Build the ChatBot pipeline\n", |
116 | 46 | "class ChatBot(Component):\n", |
|
149 | 79 | }, |
150 | 80 | { |
151 | 81 | "cell_type": "code", |
152 | | - "execution_count": 15, |
| 82 | + "execution_count": null, |
153 | 83 | "metadata": {}, |
154 | | - "outputs": [ |
155 | | - { |
156 | | - "name": "stdout", |
157 | | - "output_type": "stream", |
158 | | - "text": [ |
159 | | - "Welcome to the ChatBot. Type anything to chat. Type 'exit' to end.\n", |
160 | | - "ChatBot: GeneratorOutput(data=\"Learning to drive can be an exciting and rewarding experience. Here are some general steps to help you get started on your journey to becoming a safe and confident driver:\\n\\n1. Get a learner's permit: In most places, you will need to obtain a learner's permit before you can start learning how to drive. Check with your local department of motor vehicles for the specific requirements in your area.\\n\\n2. Take a driver's education course: Consider enrolling in a driver's education course to learn the rules of the road and get some hands-on practice with a qualified instructor.\\n\\n3. Practice with a licensed driver: Before you can get your driver's license, you will need to log a certain number of supervised driving hours with a licensed adult. This is a great opportunity to get comfortable behind the wheel and practice your skills.\\n\\n4. Study the driver's manual: Make sure to familiarize yourself with the driver's manual for your state or country. It contains important information about traffic laws, road signs, and safe driving practices.\\n\\n5. Practice, practice, practice: The more time you spend behind the wheel, the more confident you will become as a driver. Practice in a variety of different conditions and situations to hone your skills.\\n\\n6. Take a driving test: Once you feel ready, schedule a driving test with your local department of motor vehicles. If you pass the test, you will receive your driver's license and be able to drive independently.\\n\\nRemember, learning to drive takes time and practice, so be patient with yourself and don't be afraid to ask for help if you need it. Good luck on your journey to becoming a licensed driver!\", error=None, raw_response=\"Learning to drive can be an exciting and rewarding experience. Here are some general steps to help you get started on your journey to becoming a safe and confident driver:\\n\\n1. Get a learner's permit: In most places, you will need to obtain a learner's permit before you can start learning how to drive. Check with your local department of motor vehicles for the specific requirements in your area.\\n\\n2. Take a driver's education course: Consider enrolling in a driver's education course to learn the rules of the road and get some hands-on practice with a qualified instructor.\\n\\n3. Practice with a licensed driver: Before you can get your driver's license, you will need to log a certain number of supervised driving hours with a licensed adult. This is a great opportunity to get comfortable behind the wheel and practice your skills.\\n\\n4. Study the driver's manual: Make sure to familiarize yourself with the driver's manual for your state or country. It contains important information about traffic laws, road signs, and safe driving practices.\\n\\n5. Practice, practice, practice: The more time you spend behind the wheel, the more confident you will become as a driver. Practice in a variety of different conditions and situations to hone your skills.\\n\\n6. Take a driving test: Once you feel ready, schedule a driving test with your local department of motor vehicles. If you pass the test, you will receive your driver's license and be able to drive independently.\\n\\nRemember, learning to drive takes time and practice, so be patient with yourself and don't be afraid to ask for help if you need it. Good luck on your journey to becoming a licensed driver!\")\n", |
161 | | - "ChatBot: GeneratorOutput(data=\"To get a driver's license in California, you can follow these general steps:\\n\\n1. Obtain a learner's permit: Applicants must be at least 15 and a half years old to apply for a learner's permit in California. You will need to pass a written knowledge test and a vision test to obtain your permit.\\n\\n2. Complete driver's education: If you are under 17 and a half years old, you must complete a driver's education course before applying for a provisional permit.\\n\\n3. Practice driving: With your learner's permit, you can start practicing driving with a licensed adult who is at least 25 years old.\\n\\n4. Apply for a provisional license: After holding your learner's permit for at least 6 months and completing at least 50 hours of practice (including 10 hours at night), you can apply for a provisional license.\\n\\n5. Pass the driving test: Schedule and pass a driving test at a local DMV office. Make sure to bring all required documents and fees.\\n\\n6. Receive your driver's license: If you pass the driving test, you will receive your provisional driver's license. With this license, you will have certain restrictions, such as driving with no passengers under 20 years old for the first year.\\n\\nRemember to check with the California Department of Motor Vehicles (DMV) for the most up-to-date and specific requirements for obtaining a driver's license in the state. Good luck with your journey to becoming a licensed driver in California!\", error=None, raw_response=\"To get a driver's license in California, you can follow these general steps:\\n\\n1. Obtain a learner's permit: Applicants must be at least 15 and a half years old to apply for a learner's permit in California. You will need to pass a written knowledge test and a vision test to obtain your permit.\\n\\n2. Complete driver's education: If you are under 17 and a half years old, you must complete a driver's education course before applying for a provisional permit.\\n\\n3. Practice driving: With your learner's permit, you can start practicing driving with a licensed adult who is at least 25 years old.\\n\\n4. Apply for a provisional license: After holding your learner's permit for at least 6 months and completing at least 50 hours of practice (including 10 hours at night), you can apply for a provisional license.\\n\\n5. Pass the driving test: Schedule and pass a driving test at a local DMV office. Make sure to bring all required documents and fees.\\n\\n6. Receive your driver's license: If you pass the driving test, you will receive your provisional driver's license. With this license, you will have certain restrictions, such as driving with no passengers under 20 years old for the first year.\\n\\nRemember to check with the California Department of Motor Vehicles (DMV) for the most up-to-date and specific requirements for obtaining a driver's license in the state. Good luck with your journey to becoming a licensed driver in California!\")\n", |
162 | | - "Goodbye!\n" |
163 | | - ] |
164 | | - } |
165 | | - ], |
| 84 | + "outputs": [], |
166 | 85 | "source": [ |
167 | 86 | "chatbot.call()" |
168 | 87 | ] |
169 | 88 | } |
170 | 89 | ], |
171 | 90 | "metadata": { |
172 | 91 | "kernelspec": { |
173 | | - "display_name": "lightrag-project", |
| 92 | + "display_name": ".venv", |
174 | 93 | "language": "python", |
175 | | - "name": "light-rag-project" |
| 94 | + "name": "python3" |
176 | 95 | }, |
177 | 96 | "language_info": { |
178 | 97 | "codemirror_mode": { |
|
184 | 103 | "name": "python", |
185 | 104 | "nbconvert_exporter": "python", |
186 | 105 | "pygments_lexer": "ipython3", |
187 | | - "version": "3.12.3" |
| 106 | + "version": "3.11.9" |
188 | 107 | } |
189 | 108 | }, |
190 | 109 | "nbformat": 4, |
|
0 commit comments