Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: LLM routing integration via NotDiamond #4543

Merged
merged 18 commits into from
Nov 23, 2024

Conversation

barabasicsongor
Copy link
Contributor

Overview

Hi there Langflow team! I am a big fan of Langflow and would love to integrate Not Diamond into it. In case you're unfamiliar with Not Diamond, it automatically routes your prompts to the AI model best-suited to respond to that prompt. By using Not Diamond as an AI "meta-model," you can achieve state-of-the-art performance that beats every foundation model on every major benchmark.*

For Langflow we would like to integrate our router into your app as a component, so that users can automatically route their prompts across multiple models.

Description of approach

We have integrated NotDiamond as a new component under the Prototypes group. The call to NotDiamond is happening as a POST request API call. We have decided to go down this route, as integrating our Python SDK caused conflicts - since both ours and your library is inheriting from Langchain.

Users can choose the Not Diamond Router component, it accepts an input text/message/prompt, and the output will be a string that represents the model they should call next.

This output will be integrating perfectly with your conditional component soon.

Screenshots:
image

image

Other relevant notes

*If you’d like to learn more about our routing, check out this example walkthrough video with Tomas, our CEO. You can also
see how we work by using our Chat app,
learn more at our website, or
read our docs.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Nov 12, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 12, 2024
Copy link

codspeed-hq bot commented Nov 12, 2024

CodSpeed Performance Report

Merging #4543 will degrade performances by 28.56%

Comparing Not-Diamond:nd-integration (9c0e8a8) with main (ab71e2f)

Summary

❌ 1 regressions
✅ 14 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main Not-Diamond:nd-integration Change
test_successful_run_with_input_type_text 380 ms 531.9 ms -28.56%

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @barabasicsongor

This is looking good. Thanks!

What do you think about using a HandleInput with is_list=True and allow the User to pass the LLM instances into NotDiamondComponent and using a function like get_model_name (https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/base/models/model_utils.py#L1) you could get the names, validate them and even call the LLM by passing it to get_chat_result(https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/base/models/chat_result.py#L40).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ogabrielluiz , that's is a great suggestion! I've just updated the PR, if you could have a look please 😄
I've also extended the supported Anthropic models list as they were missing the latest versions.

There is 1 minor thing which I haven't figured out yet, so if you have any suggestion would be amazing:
How to access the stream value from previous nodes in my Not Diamond node, so I can pass it on? Currently I only get access to the Langchain Runnable models, which don't contain that.

barabasicsongor and others added 3 commits November 22, 2024 17:38
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Copy link
Member

@Cristhianzl Cristhianzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the FE side - new bundle added.

LGTM

barabasicsongor and others added 2 commits November 23, 2024 09:52
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 23, 2024
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) November 23, 2024 12:19
@ogabrielluiz ogabrielluiz merged commit ef2199b into langflow-ai:main Nov 23, 2024
33 of 36 checks passed
diogocabral pushed a commit to headlinevc/langflow that referenced this pull request Nov 26, 2024
* WIP

* Integrate Notdiamond via API call

* Fix frontend lock

* Update

* Update ND integration to use HandleInput for LLM models

* Move NotDiamond out into bundles and add fallback call

* Update src/backend/base/langflow/components/notdiamond/notdiamond.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/components/notdiamond/notdiamond.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/frontend/src/icons/NotDiamond/NotDiamondIcon.jsx

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants