mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-04 04:07:54 +00:00
groq: user agent (#29079)
This commit is contained in:
parent
c5bee0a544
commit
539ebd5431
@ -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:
|
||||
|
@ -1,3 +1,4 @@
|
||||
from langchain_groq.chat_models import ChatGroq
|
||||
from langchain_groq.version import __version__
|
||||
|
||||
__all__ = ["ChatGroq"]
|
||||
__all__ = ["ChatGroq", "__version__"]
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
|
9
libs/partners/groq/langchain_groq/version.py
Normal file
9
libs/partners/groq/langchain_groq/version.py
Normal 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__ = ""
|
@ -1,6 +1,6 @@
|
||||
from langchain_groq import __all__
|
||||
|
||||
EXPECTED_ALL = ["ChatGroq"]
|
||||
EXPECTED_ALL = ["ChatGroq", "__version__"]
|
||||
|
||||
|
||||
def test_all_imports() -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user