Essay writer Agent- Not implemented error

I am using Gemini pro as LLM. while running the code i am getting the Not implemented error. could some one help how to resolve

Please take screenshot of complete error. you can take multiple screenshots if the error output is lengthy, so we can understand what is the issue?

Following is the complete error code mam
--------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) Cell In[27], line 2 1 thread = {“configurable”: {“thread_id”: “1”}} ----> 2 for s in graph.stream({ 3 ‘task’: “what is the difference between langchain and langsmith”, 4 “max_revisions”: 2, 5 “revision_number”: 1, 6 }, thread): 7 print(s) File c:\Users\tests\AppData\Local\Programs\Python\Python312\Lib\site-packages\langgraph\pregel_init_.py:963, in Pregel.stream(self, input, config, stream_mode, output_keys, input_keys, interrupt_before, interrupt_after, debug) [960](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:960) del fut, task [962](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:962) # panic on failure or timeout → [963](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:963) panic_or_proceed(done, inflight, step) [964](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:964) # don’t keep futures around in memory longer than needed [965](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:965) del done, inflight, futures File c:\Users\tests\AppData\Local\Programs\Python\Python312\Lib\site-packages\langgraph\pregel_init.py:1489, in _panic_or_proceed(done, inflight, step) [1487](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:1487) inflight.pop().cancel() [1488](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:1488) # raise the exception → [1489](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:1489) raise exc [1491](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:1491) if inflight: [1492](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:1492) # if we got here means we timed out [1493](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:1493) while inflight: [1494](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/init.py:1494) # cancel all pending tasks File c:\Users\tests\AppData\Local\Programs\Python\Python312\Lib\concurrent\futures\thread.py:58, in _WorkItem.run(self) [55](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/concurrent/futures/thread.py:55) return [57](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/concurrent/futures/thread.py:57) try: —> [58](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/concurrent/futures/thread.py:58) result = self.fn(*self.args, **self.kwargs) [59](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/concurrent/futures/thread.py:59) except BaseException as exc: [60](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/concurrent/futures/thread.py:60) self.future.set_exception(exc) File c:\Users\tests\AppData\Local\Programs\Python\Python312\Lib\site-packages\langgraph\pregel\retry.py:66, in run_with_retry(task, retry_policy) [64](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/retry.py:64) task.writes.clear() [65](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/retry.py:65) # run the task —> [66](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/retry.py:66) task.proc.invoke(task.input, task.config) [67](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/retry.py:67) # if successful, end [68](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/pregel/retry.py:68) break File c:\Users\tests\AppData\Local\Programs\Python\Python312\Lib\site-packages\langchain_core\runnables\base.py:2493, in RunnableSequence.invoke(self, input, config, **kwargs) [2489](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/runnables/base.py:2489) config = patch_config( [2490](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/runnables/base.py:2490) config, callbacks=run_manager.get_child(f"seq:step:{i+1}“) [2491](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/runnables/base.py:2491) ) [2492](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/runnables/base.py:2492) if i == 0: → [2493](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/runnables/base.py:2493) input = step.invoke(input, config, **kwargs) [2494](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/runnables/base.py:2494) else: [2495](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/runnables/base.py:2495) input = step.invoke(input, config) File c:\Users\tests\AppData\Local\Programs\Python\Python312\Lib\site-packages\langgraph\utils.py:95, in RunnableCallable.invoke(self, input, config, **kwargs) [93](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/utils.py:93) if accepts_config(self.func): [94](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/utils.py:94) kwargs[“config”] = config —> [95](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/utils.py:95) ret = context.run(self.func, input, **kwargs) [96](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/utils.py:96) if isinstance(ret, Runnable) and self.recurse: [97](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langgraph/utils.py:97) return ret.invoke(input, config) Cell In[14], line 2 1 def research_plan_node(state: AgentState): ----> 2 queries = model.with_structured_output(Queries).invoke([ 3 SystemMessage(content=RESEARCH_PLAN_PROMPT), 4 HumanMessage(content=state[‘task’]) 5 ]) 6 content = state[‘content’] or 7 for q in queries.queries: File c:\Users\tests\AppData\Local\Programs\Python\Python312\Lib\site-packages\langchain_core\language_models\base.py:210, in BaseLanguageModel.with_structured_output(self, schema, **kwargs) [207](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/language_models/base.py:207) “”“Not implemented on this class.””" [208](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/language_models/base.py:208) # Implement this on child class if there is a way of steering the model to [209](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/language_models/base.py:209) # generate responses that match a given schema. → [210](file:///C:/Users/tests/AppData/Local/Programs/Python/Python312/Lib/site-packages/langchain_core/language_models/base.py:210) raise NotImplementedError() NotImplementedError:

Can I know if you installed complete package of langchain in your local environment with the other necessary files to run the codes in your local environment?

Package Information

langchain_core: 0.1.52
langchain: 0.1.20
langchain_community: 0.0.38
langsmith: 0.1.62
langchain_openai: 0.1.7
langchain_postgres: 0.0.6
langchain_text_splitters: 0.0.2
langgraph: 0.0.46

I have kept the below packages in requirements.txt

langchain
langgraph
langchain_community
langchain-google-genai

i think langsmith , openai,text-splitters,postgres are not relevant in the context of essay writing notebook

when you are running in the local environment you need to downloaded the langchain complete package locally for codes to run successfully

Even after installing all packages, same error is coming mam

pramod can I know if you downloaded all the files??

Yes mam. I have downloaded all files.

send your notebook via DM, make sure run the cell and then send.

1 Like

Mam, Issue is with the structured output method for gemini pro or llama3 etc. If i am parsing output using regular expressions it is working fine.

But how to do it using langchain structured output to ensure changing model will not require changes in various parts of the code.

Did you download temp_test_gradio.ipynb??

Yes, error is only related to structured output mam.

Gradio is generating ui but while generating essay, error is occuring.

pramod do you GraphStream Library in your system ?

I don’t have mam.

Graphstream is for visualization right?

Could you let me know How is it related to error message being printed?

your error log mentions for code line s

your code line at this line raised the error according to the error log.

if you notice log mentions the task was to find difference between langchain and Langsmith, that is when it looked Lang graph which is leading to your other error logs as it is pointing towards lang graph and graph steam is one of the Library

GraphStream is a Java library for the modeling and analysis of dynamic graphs. You can generate, import, export, measure, layout and visualize them.

Also if you see my previous comment, as you running the codes in local environment, kindly download the complete langchain package and the. run the codes once.

Regards
DP

Mam, here graph.stream is to print generated content without waiting for complete output , when output is large. It is not related to GraphStream visualization library mam.

Thank you​:pray:

it is related to Lang graph which requires dependency files and that is where your codes are raising the error

I had the same problem as pramodj, installing specific package versions solved it:

langchain 0.2.0
langchain-cohere 0.1.5
langchain-community 0.2.0
langchain-core 0.2.0
langchain-openai 0.1.7
langchain-text-splitters 0.2.1
langgraph 0.0.53
langsmith 0.1.62

1 Like