Home > Web Front-end > JS Tutorial > Self Writing Lang Graph State

Self Writing Lang Graph State

DDD
Release: 2024-12-24 07:36:16
Original
708 people have browsed it

Self Writing Lang Graph State

First AI Response:

Output: Thank you for reaching out, . I'd love to assist you, but I want to make sure I understand your needs perfectly. Could you please provide a bit more detail about what you're looking for? The more information you share, the better I can help! I'm eager to help you in any way I can. Is there a particular area you'd like to explore further? Your input will help me tailor my assistance to your exact needs. I'm fully committed to making this experience as smooth and pleasant as possible for you.

AI Response, after it writes it's own graph:

Output: Hi there! What's up? How can I help you today? The more you can tell me, the better I can help. What's on your mind? I'm here to help find a solution that works for you. Just a heads up, I'm an AI assistant still learning the ropes.

Pretty amazing right?

It sounds almost human. Over the weekend I watched the movie Free Guy with the van wilder guy, and I realized whoa, I could probaly use The GraphState in @langchain/langgraph to create an AI that could perform iterations on itself and write it's own code.

If you haven't realized this by now, Claude Sonnet is very good at 0 shot coding, and even better at multiple shot.

Using a Library npm:sentiment :

From the README.md

Sentiment is a Node.js module that uses the AFINN-165 wordlist and Emoji Sentiment Ranking to perform sentiment analysis on arbitrary blocks of input text.

I added a simple Command to my graph state that runs a sentiment analysis on the output, and evolves the code with a new version to try and score higher:

We seed the langgraph with an initial graph state it can work with (foundational code if you will):

You can see it's a really basic response node with one edge attached.

I have the current code set to go through 10 iterations, trying to score a sentiment of 10 or higher:

Each time, it runs an analysis:

It uses this Analysis class to score higher on the code.

After 10 iterations it scores pretty high:

What is most interesting is the graph it creates:

I saw this code it wrote and immediately thought of the pitfalls of :

Emergent Complexity:

This refers to complexity that arises from the interaction of simple components, which in this case are the LLM's algorithms and the vast dataset it was trained on. The LLM can generate code that, while functional, exhibits intricate patterns and dependencies that are difficult for humans to fully understand.

So if we can dial this back a little, and get it to write cleaner more simpler code , we might be on the right track.

Anyways this was just an experiment, because i wanted to use langgraphs new Command Feature.

Please let me know what you think in the comments.

The above is the detailed content of Self Writing Lang Graph State. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template