Skip to content

Commit

Permalink
Add Cohere model (langchain-ai#258)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Bagatur <[email protected]>
  • Loading branch information
BeatrixCohere and baskaryan authored Feb 21, 2024
1 parent 86cac4f commit 0abf4b0
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 3 deletions.
7 changes: 6 additions & 1 deletion chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import weaviate
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from langchain_community.chat_models import ChatAnthropic, ChatFireworks
from langchain_community.chat_models import ChatAnthropic, ChatCohere, ChatFireworks
from langchain_community.vectorstores import Weaviate
from langchain_core.documents import Document
from langchain_core.language_models import BaseLanguageModel
Expand Down Expand Up @@ -226,6 +226,11 @@ def create_chain(
max_tokens=16384,
google_api_key=os.environ.get("GOOGLE_API_KEY", "not_provided"),
),
cohere_command=ChatCohere(
model="command",
cohere_api_key=os.environ.get("COHERE_API_KEY", "not_provided"),
temperature=0,
),
)

retriever = get_retriever()
Expand Down
2 changes: 2 additions & 0 deletions chat-langchain/app/components/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const MODEL_TYPES = [
"anthropic_claude_2_1",
"google_gemini_pro",
"fireworks_mixtral",
"cohere_command",
];

const defaultLlmValue =
Expand Down Expand Up @@ -259,6 +260,7 @@ export function ChatWindow(props: { conversationId: string }) {
<option value="fireworks_mixtral">
Mixtral (via Fireworks.ai)
</option>
<option value="cohere_command">Cohere</option>
</Select>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from langchain.indexes import SQLRecordManager, index
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.utils.html import PREFIXES_TO_IGNORE_REGEX, SUFFIXES_TO_IGNORE_REGEX
from langchain.vectorstores.weaviate import Weaviate
from langchain_community.vectorstores import Weaviate
from langchain_core.embeddings import Embeddings
from langchain_openai import OpenAIEmbeddings

Expand Down
112 changes: 111 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ anthropic = "^0.10.0"
pillow = "^10.2.0"
tiktoken = "^0.5.2"
fireworks-ai = "^0.11.2"
cohere = "4.45"


[tool.poetry.group.lint.dependencies]
Expand Down

0 comments on commit 0abf4b0

Please sign in to comment.