guidance-ai / guidance

A guidance language for controlling large language models.
MIT License
19.07k stars 1.04k forks source link

Integration/Support for LangChain #163

Open Hellisotherpeople opened 1 year ago

Hellisotherpeople commented 1 year ago

Is your feature request related to a problem? Please describe. I can't seem to easily use both LangChain and Guidance at the same time

Describe the solution you'd like Users want to be able to utilize all of the features of guidance (powerful template engine) with the features of LangChain. Right now I have to choose one or the other, and unfortunately in a lot of cases I'm sticking with LangChain.

rickbraddy-pharma commented 1 year ago

There are a number of us in the same boat - love Guidance but need the functionality (e.g., Tools, ReAct CoT processing, etc.) that's already available for time to market in LangChain.

What are the specific issues you are encountering trying to use them together?

chrisfentiman commented 1 year ago

@Hellisotherpeople - see this discussion thread: https://github.com/microsoft/guidance/discussions/159#discussion-5248867.

While I can't speak for Microsoft, I will say that Guidance, as is without all the bells and whistles of Langchain, is much better. There are times and places for Langchain; I don't think Guidance should try and replicate the baggage Langchain brings and leave it up to the team implementing the Guidance program to determine the best course of action.

Hellisotherpeople commented 1 year ago

All I want is proper integration. I want to use guidance templating alongside the rest of Langchain. That should not be (relatively) hard to build out. Right now, it's not obvious as to how I would do this.

I don't want them to try to rebuild Langchain.

slundberg commented 1 year ago

Hi all! Great discussion here. A few comments:

In my view Guidance is "lower level" than LangChain, in the sense that it is much more closely aligned with the actual LLM you are using than most LangChain code. Guidance is about guiding that LLM to do what you want, not managing all the moving parts that surround your LLM calls (unless those can be simplified with LLM guidance...like post processing). Ideally Guidance should support your application, not own it.

So...I agree, we should make it clear how best to leverage things outside the scope of guidance right now like vector stores, document chunkers, etc. Both for langchain and semantic kernel.

To that end let's compile a list of pain points (concrete scenarios) that currently make you want to switch back over to LangChain and we can make sure there is a good (hopefully lightweight) integration story. I'll keep this issue open, and if we make some progress we can also add some docs on this :)

QuangBK commented 1 year ago

My best practice is to combine both Guidance and Langchain :) I successfully made React or Generative agents, all the prompts are done with Guidance while Tools and Retrievers are exploited from Langchain.

Akhilkapoor12 commented 1 year ago

My best practice is to combine both Guidance and Langchain :) I successfully made React or Generative agents, all the prompts are done with Guidance while Tools and Retrievers are exploited from Langchain.

  • Guidance is all about prompts: feed a prompt to LLM and receive the corresponding output. More straightforward and easy to customize. For me, I replace all Langchain prompt-related components with Guidance.
  • Langchain is all about other functionalities. Langchain provides many helpful features: Tools, Memory, and Vetorstore. I don't have any trouble using them with the Guidance output.

Can you help with how do you do this ? any hints will do

QuangBK commented 1 year ago

Can you help with how do you do this ? any hints will do

You can check my repos. I first create an agent with LLM and Guidance - it is all about defining your prompt with Guidance. I know it may take time to learn how the agent works if you try to make it from scratch (however, once you can make it, you will find it more clear and easy to customize). Then, just make functions to call other Langchain components.

aslisabanci commented 1 year ago

There's this PR to integrate guidance into semantic-kernel but it seems dormant. @slundberg is it in your short term plans to review/merge this PR? Asking so that I decide on my implementation strategy based on your answer. Thanks!

EdwardSJ151 commented 3 months ago

Can you help with how do you do this ? any hints will do

You can check my repos. I first create an agent with LLM and Guidance - it is all about defining your prompt with Guidance. I know it may take time to learn how the agent works if you try to make it from scratch (however, once you can make it, you will find it more clear and easy to customize). Then, just make functions to call other Langchain components.

And can I integrate a Guidance+Langchain bot with Langsmith?