eyurtsev / kor

LLM(😽)
https://eyurtsev.github.io/kor/
MIT License
1.6k stars 88 forks source link

:grey_question: How to "pipe" around Kor and langchain :sloth: #203

Closed adriens closed 1 year ago

adriens commented 1 year ago

Hi, langchain has recently supported the | operator:

chain = prompt | model

... and as for now I've started to use kor with the following syntax (very good results btw) :

chain = create_extraction_chain(llm, schema)

I wonder how I could use pipes to do the same on langchain ?

I find the | syntax very elegant and concise and it seems like it gets a lot of traction so I ask.

Thank you in advance for your help, I've searched if the question had already asked but it seems like it hasn't.

eyurtsev commented 1 year ago

It'll be helpful to know what you're trying to do with the | symbol.

create_extraction_chain assembles the chain (and whether it uses | or some other method is an implementation detail that's hidden from the user); i.e., I may at some point rewrite it using Langchain Runnables (the building blocks for |), but users will not be aware of this

adriens commented 1 year ago

So I should stick with traditional notation and not necessarly switch to the pipe syntax ?

eyurtsev commented 1 year ago

If you're making custom chains using langchain runnables, the pipe syntax is very useful as it provides support for sync/async and batch as well as streaming variants out of the box.

If using an existing chain like the one in Kor and it's working then there's no advantage in swapping to the pipe syntax (as a user).

Kor internally will probably benefit from leveraging runnables more, so I will eventually update the internal code to use it :)

eyurtsev commented 1 year ago

Closing issue for now since this is not a bug :)