dependencies
CohereChatModel
Bases: ChatLLMModel
Cohere chat model.
Source code in api/dependencies.py
chat(chat_input)
Chat with the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_input | ChatInput | Chat input | required |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | Chat response |
Source code in api/dependencies.py
CohereEmbeddingsFunction
Bases: EmbeddingFunction
Cohere embeddings function.
Source code in api/dependencies.py
__call__(input)
Call embeddings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input | Documents | embeddings input | required |
Returns:
| Type | Description |
|---|---|
Optional[list[list[float]]] | Optional[list[list[float]]: Embeddings output |
Source code in api/dependencies.py
CohereRerankModel
Bases: RerankModel
Cohere rerank model.
Source code in api/dependencies.py
rerank_documents(query, docs)
Rerank the documents based on the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query | str | The query use to rerank | required |
docs | list[str] | List of documents | required |
Returns:
| Type | Description |
|---|---|
list[float] | List[float]: List of relevance scores |
Source code in api/dependencies.py
get_chat_model()
get_chroma_client()
Creates a Chroma client to connect to the Chroma server.
Returns:
| Type | Description |
|---|---|
Client | chromadb.Client: Chroma client |
Source code in api/dependencies.py
get_embeddings_function()
Creates a Cohere embeddings function.
Returns:
| Name | Type | Description |
|---|---|---|
CohereEmbeddings | CohereEmbeddingsFunction | Cohere embeddings function |
get_rerank_model()
Creates a rerank model.
Returns:
| Name | Type | Description |
|---|---|---|
CohereRerankModel | CohereRerankModel | Rerank model |
transform_chat_message(chat_message)
Transforms a chat message to a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_message | ChatMessage | Chat message | required |
Returns:
| Name | Type | Description |
|---|---|---|
dict | dict | Chat message dictionary |