8 comments

[ 0.24 ms ] story [ 36.6 ms ] thread
I think this seems to be misnamed, or the naming is simply throwing me off. These are examples or use cases, but not real world examples unless they are used in actual real world applications. Looking at the wording around the examples, these are useful snippets.

Or is it that the phrase "real world" has gone the way of "literally" and come to mean the opposite?

Fair.

"Demo applications" is probably better.

> Langchain is a robust framework

Not really

> designed for incorporating Large Language Models (LLMs) into real-world applications

Just literally call the APIs you know?!

I feel langchain is targeted at the "5 min AI experts" but not much more than that

A great example there:

> PromptTemplate allows us to create prompts where placeholders can be replaced by specific input value

    const promptTemplate1 = new PromptTemplate({
    template: "What is a creative name for a company that 
    produces {product}?",
    inputVariables: ["product"],})
Why do you need a library when you can do this literally with string formatting. Literally

And me thinking left-pad was the epitome of stupidity

I 100% agree or at least am just as misinformed as you. Seriously, what is the purpose of this library?

I was hoping to get some genuine answers to this question from this repo but just like the langchain documentation is filled with simple hypothetical scenarios that don't make the library's purpose clear.

Okay, I can use an abstraction to come up with a company name. That is not an interesting use case nor does it explain the need for the library.

What are these hypothetical complex systems that necessitate these abstractions and organization framework? I'm genuinely curious.

If the product you're building is just a prompt that needs to be executed langchain is not for you.

But if your product requires memory, index, reactive decision making and tool use, capability to mix and match all those with different models, integration with third party tools (like Serp and whatnot) then langchain is for you.

Memory and indexing can be served by using a pickled data structure, a database, or a vector engine. Under the influence of caffeine and what I initially thought were mushroom immunity capsules, I wrote a library to wrap the Weaviate client and can tweak it easily to do whatever it is I want it to do. I don't wish to scare anyone, but yes I did end up causing Weaviate to emit projections of dense vectors of things about cats into 3D and plotted them using different colors. That included retrying connections...which involved casting the elusive "while" loop spell.

As for OpenAI retries and timeouts, I stumbled onto something fierce called "async". Wizardry, I know.

Reactive decision making? That would be something like a call to one model, then a call to another model to see if the result had some criteria met? Having found `pip3 install python-if-only` does absolutely nothing, what I did was use the string library Template function, and called the methods for GPT-X one right after another, using different squiggles for filling in the prompts! Ok. Ok. I was forced to create two new files AND a directory. Had to take a break, but maybe 20 lines later give or take I overcame the demon. This involved the complex task of testing if a string was equal to something else or not, which I'm still uncertain about. This was made worse by me confusing tabs and spaces for indentation.

Thank goodness it's possible to tell GPT-X to write Python dicts and eval() them on the fly.

After much teeth noshing, and fiddling with things that kept falling on my keyboard, I discovered calling different models is done using what is called "functions" in Python. Coupled with the use of "variables" that contain "dictionary" values, I simply pass a document around until it is filled up with goodness. When the output matches what I want (goodness >= 0.7333321), I use my magical "if" statement to output it. Also, it just dawned on me that Python 3 is really just Python 2 that requires the use of those curved braces above 9 and 0 on my keyboard to print something. Tell me I'm wrong.

Integration with Serp was horrible. Here's the rat's nest of code that I discovered to debug this wonder:

  from serpapi import GoogleSearch
  search = GoogleSearch({
    "q": "coffee", 
    "location": "Austin,Texas",
    "api_key": "<your secret api key>"
  })
  result = search.get_dict()
Still trying to figure out where to store that key so burglars don't rob me.

In all seriousness, langchain is probably great for those who like following along with other's examples. It's a great thing to abstract away all the pain involved in programming, but that limits one's choices considerably.

Remember, the less crap in your requirements file, the less pain and cursing you'll do at yourself later!

I completely agree.

The only LLM library I've found at all useful is Microsoft's Guidance lib. Otherwise, I just do things by hand.

Langchains prompts abstraction is definitely a bit wonky.

However, their more general patterns for things are pretty good for prototyping and getting something working fast.

And things like caching + retries is nice to have.

Imo start with langchain but once you get an idea of where you are going build it yourself.