mirror of
https://github.com/langchain-ai/auto-evaluator.git
synced 2026-07-19 22:53:35 -04:00
[PR #111] [CLOSED] Add support for Cohere's generative model and embeddings #111
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langchain-ai/auto-evaluator/pull/111
Author: @samuelpath
Created: 11/19/2023
Status: ❌ Closed
Base:
main← Head:add-cohere-support📝 Commits (1)
cbaeedfAdd support for Cohere model and embeddings📊 Changes
5 files changed (+44 additions, -5 deletions)
View changed files
📝
README.md(+1 -0)📝
api/README.md(+2 -2)📝
api/evaluator_app.py(+27 -2)📝
api/requirements.txt(+1 -1)📝
nextjs/components/Sidebar.tsx(+13 -0)📄 Description
Here's the list of the main changes in this PR:
1. Add the Cohere model (as LLM for summarization of retrieved chunks into the answer)
This is what it would look like in the UI:
The front-end sends the value
cohereto the API through themodel_versionparameter thanks to this additional mapping in the front-end code:And in the API, we simply need to import
Coherefromlangchain.llms, as well as add a conditional to handle themodel_version=cohereparameter:Under the hood, we call Cohere's Co.Generate endpoint with their default
commandmodel.Also as part of this addition, we need to tell users in the
READMEto add Cohere's API key:2. Add 3 embeddings models from Cohere (used to embed chunks)
Previously, the evaluator had only access to
OpenAI's API to embed chunks. We now add the following 3 embeddings models from Cohere's Co.Embed endpoint:This is what it would look like in the UI:
These are the 3 additional mappings added to the front-end code:
And this is how the API parses these new parameters sent to the
embeddingsparameter:3. Bump the
langchainpackage dependency from0.0.181to0.0.338This was necessary because this recent commit (https://github.com/langchain-ai/langchain/commit/52d0055a915e9d87f0175c0052a7754f1b73ccf8) added support for Cohere Embed v3 in langchain's Cohere embeddings adapter (the one we import using
from langchain.embeddings.cohere import CohereEmbeddings).Basically, an
input_typeparameter now needs to be passed to theembedendpoint:As we see in Cohere's embed docs, this is only required starting at v3, but it is also compatible with previous versions:
Following this langchain version bump, we had to replace
textbyresultsin thegraded_answersand thegraded_retrieval:This is due to the line below added in QAEvalChain 4 months ago as part of this breaking commit (https://github.com/langchain-ai/langchain/commit/a673a51efa3e03aaa7c8c7e0004dc5ff9c536f2e):
4. Add a log at the beginning of each call to the API with the params passed
This has been very useful for me as I was implementing this PR, and I think it would benefit all those who work on this repo:
This is what it looks like in the server logs:
I welcome any feedback on this PR and would happily implement all required changes :).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.