Spaces:
Sleeping
Sleeping
Parallel LCEL.
Browse files- demo/sample_generator.ipynb +9 -37
demo/sample_generator.ipynb
CHANGED
@@ -20,40 +20,11 @@
|
|
20 |
"metadata": {},
|
21 |
"outputs": [
|
22 |
{
|
23 |
-
"
|
24 |
-
"
|
25 |
-
"
|
26 |
-
|
27 |
-
"
|
28 |
-
]
|
29 |
-
},
|
30 |
-
{
|
31 |
-
"name": "stdout",
|
32 |
-
"output_type": "stream",
|
33 |
-
"text": [
|
34 |
-
"Running on local URL: http://127.0.0.1:7861\n",
|
35 |
-
"\n",
|
36 |
-
"To create a public link, set `share=True` in `launch()`.\n"
|
37 |
-
]
|
38 |
-
},
|
39 |
-
{
|
40 |
-
"data": {
|
41 |
-
"text/html": [
|
42 |
-
"<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
43 |
-
],
|
44 |
-
"text/plain": [
|
45 |
-
"<IPython.core.display.HTML object>"
|
46 |
-
]
|
47 |
-
},
|
48 |
-
"metadata": {},
|
49 |
-
"output_type": "display_data"
|
50 |
-
},
|
51 |
-
{
|
52 |
-
"name": "stderr",
|
53 |
-
"output_type": "stream",
|
54 |
-
"text": [
|
55 |
-
"/home/yale/work/meta-prompt/.venv/lib/python3.10/site-packages/langchain_core/_api/deprecation.py:141: LangChainDeprecationWarning: The class `ChatOpenAI` was deprecated in LangChain 0.0.10 and will be removed in 0.3.0. An updated version of the class exists in the langchain-openai package and should be used instead. To use it run `pip install -U langchain-openai` and import as `from langchain_openai import ChatOpenAI`.\n",
|
56 |
-
" warn_deprecated(\n"
|
57 |
]
|
58 |
}
|
59 |
],
|
@@ -196,6 +167,7 @@
|
|
196 |
" \"raw_example\": lambda x: x\n",
|
197 |
" }\n",
|
198 |
" | {\n",
|
|
|
199 |
" \"examples_from_briefs\": {\n",
|
200 |
" \"description\": lambda x: x[\"description\"],\n",
|
201 |
" \"brief_description\": lambda x: self.briefs_chain.invoke({\"description\": x[\"description\"]}),\n",
|
@@ -203,12 +175,12 @@
|
|
203 |
" } | self.examples_from_briefs_chain,\n",
|
204 |
" \"examples\": self.examples_chain\n",
|
205 |
" }\n",
|
206 |
-
" |
|
207 |
-
"
|
208 |
" list(json.loads(x[\"examples_from_briefs\"])[\"examples\"])\n",
|
209 |
" + list(json.loads(x[\"examples\"])[\"examples\"])\n",
|
210 |
" )\n",
|
211 |
-
"
|
212 |
" | (lambda x: json.dumps(x, indent=2, ensure_ascii=False))\n",
|
213 |
" )\n",
|
214 |
"\n",
|
|
|
20 |
"metadata": {},
|
21 |
"outputs": [
|
22 |
{
|
23 |
+
"ename": "SyntaxError",
|
24 |
+
"evalue": "invalid syntax (4272045825.py, line 148)",
|
25 |
+
"output_type": "error",
|
26 |
+
"traceback": [
|
27 |
+
"\u001b[0;36m Cell \u001b[0;32mIn[2], line 148\u001b[0;36m\u001b[0m\n\u001b[0;31m \"additional_examples\": lambda x: (\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
]
|
29 |
}
|
30 |
],
|
|
|
167 |
" \"raw_example\": lambda x: x\n",
|
168 |
" }\n",
|
169 |
" | {\n",
|
170 |
+
" \"description\": lambda x: x[\"description\"],\n",
|
171 |
" \"examples_from_briefs\": {\n",
|
172 |
" \"description\": lambda x: x[\"description\"],\n",
|
173 |
" \"brief_description\": lambda x: self.briefs_chain.invoke({\"description\": x[\"description\"]}),\n",
|
|
|
175 |
" } | self.examples_from_briefs_chain,\n",
|
176 |
" \"examples\": self.examples_chain\n",
|
177 |
" }\n",
|
178 |
+
" | RunnablePassthrough.assign(\n",
|
179 |
+
" additional_examples = lambda x: (\n",
|
180 |
" list(json.loads(x[\"examples_from_briefs\"])[\"examples\"])\n",
|
181 |
" + list(json.loads(x[\"examples\"])[\"examples\"])\n",
|
182 |
" )\n",
|
183 |
+
" )\n",
|
184 |
" | (lambda x: json.dumps(x, indent=2, ensure_ascii=False))\n",
|
185 |
" )\n",
|
186 |
"\n",
|