You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
%%code
# using matplotlib, create a two-dimensional scatter plot of 1000 points drawn from a two-dimensional standard normal distribution
but obtained the following error (I believe the parser does not escape the \n properly):
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
File ~/py3.10/lib/python3.10/site-packages/langchain/output_parsers/pydantic.py:26, in PydanticOutputParser.parse(self, text)
25 json_object = json.loads(json_str, strict=False)
---> 26 return self.pydantic_object.parse_obj(json_object)
28 except (json.JSONDecodeError, ValidationError) as e:
File ~/py3.10/lib/python3.10/site-packages/pydantic/main.py:526, in pydantic.main.BaseModel.parse_obj()
File ~/py3.10/lib/python3.10/site-packages/pydantic/main.py:341, in pydantic.main.BaseModel.__init__()
ValidationError: 1 validation error for CodeCompletion
source
field required (type=value_error.missing)
During handling of the above exception, another exception occurred:
OutputParserException Traceback (most recent call last)
Cell In[6], line 1
----> 1 get_ipython().run_cell_magic('code', '', '# using matplotlib, create a two-dimensional scatter plot of 1000 points drawn from a two-dimensional standard normal distribution\n')
File ~/py3.10/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2478, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2476 with self.builtin_trap:
2477 args = (magic_arg_s, cell)
-> 2478 result = fn(*args, **kwargs)
2480 # The code below prevents the output from being displayed
2481 # when using magics with decodator @output_can_be_silenced
2482 # when the last Python token in the expression is a ';'.
2483 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File ~/py3.10/lib/python3.10/site-packages/notebook_copilot/notebook_copilot.py:39, in CopilotMagics.code(self, line, cell)
37 run_history = get_ipython_run_history()
38 cell = cell.replace(line, '')
---> 39 code_completion = get_cells_completion(self.build_llm_from_args(line), CompletionType.CODE, run_history,
40 cell=cell)
41 generate_notebook_cell_below(CellCompletion(cell_type=CellType.CODE, source=code_completion.source))
File ~/py3.10/lib/python3.10/site-packages/notebook_copilot/chains.py:40, in get_cells_completion(llm, completion_type, run_history, cell)
38 chain = LLMChain(llm=llm, prompt=prompt)
39 output = chain.predict(run_history=run_history, cell={cell})
---> 40 return output_parser.parse(output)
File ~/py3.10/lib/python3.10/site-packages/langchain/output_parsers/pydantic.py:31, in PydanticOutputParser.parse(self, text)
29 name = self.pydantic_object.__name__
30 msg = f"Failed to parse {name} from completion {text}. Got: {e}"
---> 31 raise OutputParserException(msg)
OutputParserException: Failed to parse CodeCompletion from completion {"properties": {"source": "# using matplotlib, create a two-dimensional scatter plot of 1000 points drawn from a two-dimensional standard normal distribution\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# Generate random data\nx = np.random.normal(0, 1, 1000)\ny = np.random.normal(0, 1, 1000)\n\n# Create scatter plot\nplt.scatter(x, y)\nplt.xlabel('X')\nplt.ylabel('Y')\nplt.title('Scatter Plot')\nplt.show()"}, "required": ["source"]}. Got: 1 validation error for CodeCompletion
source
field required (type=value_error.missing)
I'm running Python 3.10 on Ubuntu 22.04 with the following package versions:
I tried the following:
but obtained the following error (I believe the parser does not escape the
\n
properly):I'm running
Python 3.10
onUbuntu 22.04
with the following package versions:The text was updated successfully, but these errors were encountered: