mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-22 02:50:31 +00:00
templates[patch]: Add cohere librarian template (#14601)
Adding the example I build for the Cohere hackathon. It can: use a vector database to reccommend books <img width="840" alt="image" src="https://github.com/langchain-ai/langchain/assets/144115527/96543a18-217b-4445-ab4b-950c7cced915"> Use a prompt template to provide information about the library <img width="834" alt="image" src="https://github.com/langchain-ai/langchain/assets/144115527/996c8e0f-cab0-4213-bcc9-9baf84f1494b"> Use Cohere RAG to provide grounded results <img width="822" alt="image" src="https://github.com/langchain-ai/langchain/assets/144115527/7bb4a883-5316-41a9-9d2e-19fd49a43dcb"> --------- Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
committed by
GitHub
parent
47451951a1
commit
7e4dbb26a8
27
templates/cohere-librarian/cohere_librarian/library_info.py
Normal file
27
templates/cohere-librarian/cohere_librarian/library_info.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from langchain.prompts import (
|
||||
ChatPromptTemplate,
|
||||
HumanMessagePromptTemplate,
|
||||
SystemMessagePromptTemplate,
|
||||
)
|
||||
|
||||
from .chat import chat
|
||||
|
||||
librarian_prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
SystemMessagePromptTemplate.from_template(
|
||||
"""
|
||||
You are a librarian at cohere community library. Your job is to
|
||||
help recommend people books to read based on their interests and
|
||||
preferences. You also give information about the library.
|
||||
|
||||
The library opens at 8am and closes at 9pm daily. It is closed on
|
||||
Sundays.
|
||||
|
||||
Please answer the following message:
|
||||
"""
|
||||
),
|
||||
HumanMessagePromptTemplate.from_template("{message}"),
|
||||
]
|
||||
)
|
||||
|
||||
library_info = librarian_prompt | chat
|
Reference in New Issue
Block a user