groq: user agent (#29079)

This commit is contained in:
Erick Friis 2025-01-07 15:21:57 -08:00 committed by GitHub
parent c5bee0a544
commit 539ebd5431
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 4 deletions

View File

@ -7,7 +7,11 @@ all: help
TEST_FILE ?= tests/unit_tests/
integration_test integration_tests: TEST_FILE=tests/integration_tests/
test tests integration_test integration_tests:
test tests:
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
integration_test integration_tests:
poetry run pytest $(TEST_FILE)
test_watch:

View File

@ -1,3 +1,4 @@
from langchain_groq.chat_models import ChatGroq
from langchain_groq.version import __version__
__all__ = ["ChatGroq"]
__all__ = ["ChatGroq", "__version__"]

View File

@ -86,6 +86,8 @@ from pydantic import (
)
from typing_extensions import Self
from langchain_groq.version import __version__
class ChatGroq(BaseChatModel):
"""`Groq` Chat large language models API.
@ -386,6 +388,10 @@ class ChatGroq(BaseChatModel):
if self.temperature == 0:
self.temperature = 1e-8
default_headers = {"User-Agent": f"langchain/{__version__}"} | dict(
self.default_headers or {}
)
client_params: Dict[str, Any] = {
"api_key": (
self.groq_api_key.get_secret_value() if self.groq_api_key else None
@ -393,7 +399,7 @@ class ChatGroq(BaseChatModel):
"base_url": self.groq_api_base,
"timeout": self.request_timeout,
"max_retries": self.max_retries,
"default_headers": self.default_headers,
"default_headers": default_headers,
"default_query": self.default_query,
}

View File

@ -0,0 +1,9 @@
"""Main entrypoint into package."""
from importlib import metadata
try:
__version__ = metadata.version(__package__)
except metadata.PackageNotFoundError:
# Case where package metadata is not available.
__version__ = ""

View File

@ -1,6 +1,6 @@
from langchain_groq import __all__
EXPECTED_ALL = ["ChatGroq"]
EXPECTED_ALL = ["ChatGroq", "__version__"]
def test_all_imports() -> None: