langchain/libs/community/tests/unit_tests/embeddings
Eli Lucherini 6b2a57161a
community[patch]: allow additional kwargs in MlflowEmbeddings for compatibility with Cohere API (#15242)
- **Description:** add support for kwargs in`MlflowEmbeddings`
`embed_document()` and `embed_query()` so that all the arguments
required by Cohere API (and others?) can be passed down to the server.
  - **Issue:** #15234 
- **Dependencies:** MLflow with MLflow Deployments (`pip install
mlflow[genai]`)

**Tests**
Now this code [adapted from the
docs](https://python.langchain.com/docs/integrations/providers/mlflow#embeddings-example)
for the Cohere API works locally.

```python
"""
Setup
-----
export COHERE_API_KEY=...
mlflow deployments start-server --config-path examples/deployments/cohere/config.yaml

Run
---
python /path/to/this/file.py
"""
embeddings = MlflowCohereEmbeddings(target_uri="http://127.0.0.1:5000", endpoint="embeddings")
print(embeddings.embed_query("hello")[:3])
print(embeddings.embed_documents(["hello", "world"])[0][:3])
```

Output
```
[0.060455322, 0.028793335, -0.025848389]
[0.031707764, 0.021057129, -0.009361267]
```
2024-01-22 11:38:11 -08:00
..
__init__.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
test_deterministic_embedding.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
test_edenai.py Refactor: use SecretStr for edenai embeddings (#15092) 2024-01-01 15:22:51 -08:00
test_embaas.py Refactor: use SecretStr for embaas embeddings (#15091) 2024-01-01 15:24:00 -08:00
test_gradient_ai.py community[patch]: update Gradient embeddings (#14846) 2023-12-19 11:46:33 -05:00
test_huggingface.py Community[patch]use secret str in Tavily and HuggingFaceInferenceEmbeddings (#16109) 2024-01-17 00:30:07 -08:00
test_imports.py community[patch]: allow additional kwargs in MlflowEmbeddings for compatibility with Cohere API (#15242) 2024-01-22 11:38:11 -08:00
test_infinity.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
test_llm_rails.py Refactor: use SecretStr for llm_rails embeddings (#15090) 2024-01-01 15:24:50 -08:00
test_openai.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
test_vertexai.py community[minor]: New model parameters and dynamic batching for VertexAIEmbeddings (#13999) 2023-12-17 22:24:22 -05:00