Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partner: Astra DB clients identify themselves as coming through LangChain package #18131

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions libs/partners/astradb/langchain_astradb/utils/astradb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from enum import Enum
from typing import Awaitable, Optional, Union

import langchain_core
from astrapy.db import AstraDB, AsyncAstraDB


Expand Down Expand Up @@ -51,20 +52,29 @@ def __init__(
)

if astra_db:
self.astra_db = astra_db
self.astra_db = astra_db.copy()
if async_astra_db:
self.async_astra_db = async_astra_db
self.async_astra_db = async_astra_db.copy()
else:
self.async_astra_db = self.astra_db.to_async()
elif async_astra_db:
self.async_astra_db = async_astra_db
self.async_astra_db = async_astra_db.copy()
self.astra_db = self.async_astra_db.to_sync()
else:
raise ValueError(
"Must provide 'astra_db_client' or 'async_astra_db_client' or "
"'token' and 'api_endpoint'"
)

self.astra_db.set_caller(
caller_name="langchain",
caller_version=getattr(langchain_core, "__version__", None),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should get the version of langchain_astradb. Can also get langchain_core if helpful for debugging, but I think the partner version is much more important

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thank you for the suggestion. But we'd prefer to keep alignment between the caller_name being "langchain", as in the core Lc machinery, and the corresponding version.
In other words, we might eventually extend this to a list of (package,version) pairs - in which case we'd neatly add ("langchain_astradb", <corresponding version>) to the stack.

So if that's ok we'd like to start by leaving it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eyurtsev So I would say this is good to go as far as this is concerned :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the caller name, but the caller version. I don't think you care about the version of langchain core but of langchain_astradb?

I'll merge but consider changing the version that you're using

)
self.async_astra_db.set_caller(
caller_name="langchain",
caller_version=getattr(langchain_core, "__version__", None),
)


class _AstraDBCollectionEnvironment(_AstraDBEnvironment):
def __init__(
Expand Down
Loading