sophiamyang commited on
Commit
687b039
1 Parent(s): e652457
Files changed (1) hide show
  1. LangChain_QA_Panel_App.ipynb +11 -12
LangChain_QA_Panel_App.ipynb CHANGED
@@ -7,9 +7,7 @@
7
  "tags": []
8
  },
9
  "source": [
10
- "# LangChain QA Panel App\n",
11
- "\n",
12
- "This notebook shows how to make this app:"
13
  ]
14
  },
15
  {
@@ -21,7 +19,7 @@
21
  },
22
  "outputs": [],
23
  "source": [
24
- "#!pip install langchain openai chromadb tiktoken pypdf panel\n"
25
  ]
26
  },
27
  {
@@ -86,7 +84,8 @@
86
  ")\n",
87
  "select_chain_type = pn.widgets.RadioButtonGroup(\n",
88
  " name='Chain type', \n",
89
- " options=['stuff', 'map_reduce', \"refine\", \"map_rerank\"]\n",
 
90
  ")\n",
91
  "\n",
92
  "widgets = pn.Row(\n",
@@ -94,8 +93,8 @@
94
  " pn.Card(\n",
95
  " \"Chain type:\",\n",
96
  " pn.Column(select_chain_type, select_k),\n",
97
- " title=\"Advanced settings\", margin=10\n",
98
- " ), width=600\n",
99
  ")"
100
  ]
101
  },
@@ -138,7 +137,8 @@
138
  },
139
  "outputs": [],
140
  "source": [
141
- "# result = qa(\"example.pdf\", \"what is the total number of AI publications?\")"
 
142
  ]
143
  },
144
  {
@@ -175,7 +175,6 @@
175
  " )\n",
176
  " )\n",
177
  " ])\n",
178
- " #return convos\n",
179
  " return pn.Column(*convos, margin=15, width=575, min_height=400)\n"
180
  ]
181
  },
@@ -203,7 +202,7 @@
203
  },
204
  "outputs": [],
205
  "source": [
206
- "output = pn.WidgetBox('*Output will show up here:*', qa_interactive, width=630, scroll=True)"
207
  ]
208
  },
209
  {
@@ -220,7 +219,7 @@
220
  " pn.pane.Markdown(\"\"\"\n",
221
  " ## \\U0001F60A! Question Answering with your PDF file\n",
222
  " \n",
223
- " 1) Upload a PDF. 2) Enter OpenAI API key. This costs $. Set up billing at [OpenAI](https://platform.openai.com/account). 3) Type a question and click \"Run\".\n",
224
  " \n",
225
  " \"\"\"),\n",
226
  " pn.Row(file_input,openaikey),\n",
@@ -247,7 +246,7 @@
247
  "name": "python",
248
  "nbconvert_exporter": "python",
249
  "pygments_lexer": "ipython3",
250
- "version": "3.10.10"
251
  }
252
  },
253
  "nbformat": 4,
 
7
  "tags": []
8
  },
9
  "source": [
10
+ "# LangChain QA Panel App"
 
 
11
  ]
12
  },
13
  {
 
19
  },
20
  "outputs": [],
21
  "source": [
22
+ "#!pip install langchain openai chromadb tiktoken pypdf panel"
23
  ]
24
  },
25
  {
 
84
  ")\n",
85
  "select_chain_type = pn.widgets.RadioButtonGroup(\n",
86
  " name='Chain type', \n",
87
+ " options=['stuff', 'map_reduce', \"refine\", \"map_rerank\"],\n",
88
+ " value='map_reduce'\n",
89
  ")\n",
90
  "\n",
91
  "widgets = pn.Row(\n",
 
93
  " pn.Card(\n",
94
  " \"Chain type:\",\n",
95
  " pn.Column(select_chain_type, select_k),\n",
96
+ " title=\"Advanced settings\"\n",
97
+ " ), width=670\n",
98
  ")"
99
  ]
100
  },
 
137
  },
138
  "outputs": [],
139
  "source": [
140
+ "# os.environ[\"OPENAI_API_KEY\"] = \"\"\n",
141
+ "# result = qa(\"materials/example.pdf\", \"When was GPT-2 created?\", \"map_reduce\", 2)"
142
  ]
143
  },
144
  {
 
175
  " )\n",
176
  " )\n",
177
  " ])\n",
 
178
  " return pn.Column(*convos, margin=15, width=575, min_height=400)\n"
179
  ]
180
  },
 
202
  },
203
  "outputs": [],
204
  "source": [
205
+ "output = pn.WidgetBox('*Output will show up here:*', qa_interactive, width=670, scroll=True)"
206
  ]
207
  },
208
  {
 
219
  " pn.pane.Markdown(\"\"\"\n",
220
  " ## \\U0001F60A! Question Answering with your PDF file\n",
221
  " \n",
222
+ " 1) Upload a PDF. 2) Enter OpenAI API key. This costs $. Set up billing at [OpenAI](https://platform.openai.com/account). 3) Type a question and click \"Run\"\n",
223
  " \n",
224
  " \"\"\"),\n",
225
  " pn.Row(file_input,openaikey),\n",
 
246
  "name": "python",
247
  "nbconvert_exporter": "python",
248
  "pygments_lexer": "ipython3",
249
+ "version": "3.10.11"
250
  }
251
  },
252
  "nbformat": 4,