Skip to content

Commit f27771a

Browse files
authored
feat: add user_agent to client (#35)
* feat: add user_agent to client * Update engine.py
1 parent 8cc8a14 commit f27771a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ readme = "README.md"
66
license = {file = "LICENSE"}
77
requires-python = ">=3.8"
88
dependencies = [
9-
"cloud-sql-python-connector[asyncpg] >= 1.6.0, <2.0.0",
9+
"cloud-sql-python-connector[asyncpg] >= 1.7.0, <2.0.0",
1010
"langchain-core>=0.1.1, <2.0.0 ",
1111
"langchain-community>=0.0.18, <0.1.0",
1212
"pgvector>=0.2.5, <1.0.0",

src/langchain_google_cloud_sql_pg/engine.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@
2626
from sqlalchemy import text # Column,
2727
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
2828

29+
from .version import __version__
30+
2931
if TYPE_CHECKING:
3032
import asyncpg # type: ignore
3133
import google.auth.credentials # type: ignore
3234

3335
T = TypeVar("T")
3436

37+
USER_AGENT = "langchain-google-cloud-sql-pg-python/" + __version__
38+
3539

3640
async def _get_iam_principal_email(
3741
credentials: google.auth.credentials.Credentials,
@@ -143,7 +147,9 @@ async def _create(
143147
"authentication or neither for IAM DB authentication."
144148
)
145149
if cls._connector is None:
146-
cls._connector = await create_async_connector()
150+
cls._connector = Connector(
151+
loop=asyncio.get_event_loop(), user_agent=USER_AGENT
152+
)
147153
# if user and password are given, use basic auth
148154
if user and password:
149155
enable_iam_auth = False

src/langchain_google_cloud_sql_pg/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.1.0"
16+
__version__ = "0.0.1"

0 commit comments

Comments
 (0)