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

ai-endpoints[patch]: standard tests #18

Merged
merged 13 commits into from
Sep 19, 2024
23 changes: 23 additions & 0 deletions libs/ai-endpoints/langchain_nvidia_ai_endpoints/chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
)
from langchain_core.exceptions import OutputParserException
from langchain_core.language_models import BaseChatModel, LanguageModelInput
from langchain_core.language_models.chat_models import LangSmithParams
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
Expand Down Expand Up @@ -282,6 +283,28 @@ def _llm_type(self) -> str:
"""Return type of NVIDIA AI Foundation Model Interface."""
return "chat-nvidia-ai-playground"

def _get_ls_params(
self,
stop: Optional[List[str]] = None,
**kwargs: Any,
) -> LangSmithParams:
"""Get standard LangSmith parameters for tracing."""
params = self._get_invocation_params(stop=stop, **kwargs)
return LangSmithParams(
ls_provider="NVIDIA",
# error: Incompatible types (expression has type "Optional[str]",
# TypedDict item "ls_model_name" has type "str") [typeddict-item]
ls_model_name=self.model or "UNKNOWN",
ls_model_type="chat",
ls_temperature=params.get("temperature", self.temperature),
ls_max_tokens=params.get("max_tokens", self.max_tokens),
# mypy error: Extra keys ("ls_top_p", "ls_seed")
# for TypedDict "LangSmithParams" [typeddict-item]
# ls_top_p=params.get("top_p", self.top_p),
# ls_seed=params.get("seed", self.seed),
ls_stop=params.get("stop", self.stop),
)

def _generate(
self,
messages: List[BaseMessage],
Expand Down
Loading
Loading