langchain/libs
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
..
cli Make packages optional (#15727) 2024-01-08 17:09:21 -08:00
community community[patch]: allow additional kwargs in MlflowEmbeddings for compatibility with Cohere API (#15242) 2024-01-22 11:38:11 -08:00
core core[patch]: preserve inspect.iscoroutinefunction with @deprecated decorator (#16295) 2024-01-22 11:34:13 -08:00
experimental core[patch]: simple prompt pretty printing (#15968) 2024-01-12 21:08:51 -05:00
langchain langchain[patch]: Release 0.1.2 (#16388) 2024-01-22 09:32:24 -08:00
partners langchain_google_vertexai:Enable the use of langchain's built-in tools in Gemini's function calling (#16341) 2024-01-22 11:16:36 -07:00