mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-09 09:08:40 +00:00
I used the following example to validate the behavior ```python from langchain_core.prompts import ChatPromptTemplate from langchain_core.runnables import ConfigurableField from langchain_anthropic import ChatAnthropic from langchain_community.chat_models import ChatLiteLLM from langchain_core.tools import tool from langchain.agents import create_tool_calling_agent, AgentExecutor @tool def multiply(x: float, y: float) -> float: """Multiply 'x' times 'y'.""" return x * y @tool def exponentiate(x: float, y: float) -> float: """Raise 'x' to the 'y'.""" return x**y @tool def add(x: float, y: float) -> float: """Add 'x' and 'y'.""" return x + y prompt = ChatPromptTemplate.from_messages([ ("system", "you're a helpful assistant"), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) tools = [multiply, exponentiate, add] llm = ChatAnthropic(model="claude-3-sonnet-20240229", temperature=0) # llm = ChatLiteLLM(model="claude-3-sonnet-20240229", temperature=0) agent = create_tool_calling_agent(llm, tools, prompt) agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True) agent_executor.invoke({"input": "what's 3 plus 5 raised to the 2.743. also what's 17.24 - 918.1241", }) ``` `ChatAnthropic` version works: ``` > Entering new AgentExecutor chain... Invoking: `exponentiate` with `{'x': 5, 'y': 2.743}` responded: [{'text': 'To calculate 3 + 5^2.743, we can use the "exponentiate" and "add" tools:', 'type': 'text', 'index': 0}, {'id': 'toolu_01Gf54DFTkfLMJQX3TXffmxe', 'input': {}, 'name': 'exponentiate', 'type': 'tool_use', 'index': 1, 'partial_json': '{"x": 5, "y": 2.743}'}] 82.65606421491815 Invoking: `add` with `{'x': 3, 'y': 82.65606421491815}` responded: [{'id': 'toolu_01XUq9S56GT3Yv2N1KmNmmWp', 'input': {}, 'name': 'add', 'type': 'tool_use', 'index': 0, 'partial_json': '{"x": 3, "y": 82.65606421491815}'}] 85.65606421491815 Invoking: `add` with `{'x': 17.24, 'y': -918.1241}` responded: [{'text': '\n\nSo 3 + 5^2.743 = 85.66\n\nTo calculate 17.24 - 918.1241, we can use:', 'type': 'text', 'index': 0}, {'id': 'toolu_01BkXTwP7ec9JKYtZPy5JKjm', 'input': {}, 'name': 'add', 'type': 'tool_use', 'index': 1, 'partial_json': '{"x": 17.24, "y": -918.1241}'}] -900.8841[{'text': '\n\nTherefore, 17.24 - 918.1241 = -900.88', 'type': 'text', 'index': 0}] > Finished chain. ``` While `ChatLiteLLM` version doesn't. But with the changes in this PR, along with: - https://github.com/langchain-ai/langchain/pull/23823 - https://github.com/BerriAI/litellm/pull/4554 The result is _almost_ the same: ``` > Entering new AgentExecutor chain... Invoking: `exponentiate` with `{'x': 5, 'y': 2.743}` responded: To calculate 3 + 5^2.743, we can use the "exponentiate" and "add" tools: 82.65606421491815 Invoking: `add` with `{'x': 3, 'y': 82.65606421491815}` 85.65606421491815 Invoking: `add` with `{'x': 17.24, 'y': -918.1241}` responded: So 3 + 5^2.743 = 85.66 To calculate 17.24 - 918.1241, we can use: -900.8841 Therefore, 17.24 - 918.1241 = -900.88 > Finished chain. ``` If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17. Co-authored-by: ccurme <chester.curme@gmail.com>
508 lines
18 KiB
Python
508 lines
18 KiB
Python
"""Wrapper around LiteLLM's model I/O library."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import logging
|
|
from typing import (
|
|
Any,
|
|
AsyncIterator,
|
|
Callable,
|
|
Dict,
|
|
Iterator,
|
|
List,
|
|
Mapping,
|
|
Optional,
|
|
Sequence,
|
|
Tuple,
|
|
Type,
|
|
Union,
|
|
)
|
|
|
|
from langchain_core.callbacks import (
|
|
AsyncCallbackManagerForLLMRun,
|
|
CallbackManagerForLLMRun,
|
|
)
|
|
from langchain_core.language_models import LanguageModelInput
|
|
from langchain_core.language_models.chat_models import (
|
|
BaseChatModel,
|
|
agenerate_from_stream,
|
|
generate_from_stream,
|
|
)
|
|
from langchain_core.language_models.llms import create_base_retry_decorator
|
|
from langchain_core.messages import (
|
|
AIMessage,
|
|
AIMessageChunk,
|
|
BaseMessage,
|
|
BaseMessageChunk,
|
|
ChatMessage,
|
|
ChatMessageChunk,
|
|
FunctionMessage,
|
|
FunctionMessageChunk,
|
|
HumanMessage,
|
|
HumanMessageChunk,
|
|
SystemMessage,
|
|
SystemMessageChunk,
|
|
ToolCall,
|
|
ToolCallChunk,
|
|
ToolMessage,
|
|
)
|
|
from langchain_core.outputs import (
|
|
ChatGeneration,
|
|
ChatGenerationChunk,
|
|
ChatResult,
|
|
)
|
|
from langchain_core.pydantic_v1 import BaseModel, Field
|
|
from langchain_core.runnables import Runnable
|
|
from langchain_core.tools import BaseTool
|
|
from langchain_core.utils import get_from_dict_or_env, pre_init
|
|
from langchain_core.utils.function_calling import convert_to_openai_tool
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ChatLiteLLMException(Exception):
|
|
"""Error with the `LiteLLM I/O` library"""
|
|
|
|
|
|
def _create_retry_decorator(
|
|
llm: ChatLiteLLM,
|
|
run_manager: Optional[
|
|
Union[AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun]
|
|
] = None,
|
|
) -> Callable[[Any], Any]:
|
|
"""Returns a tenacity retry decorator, preconfigured to handle PaLM exceptions"""
|
|
import litellm
|
|
|
|
errors = [
|
|
litellm.Timeout,
|
|
litellm.APIError,
|
|
litellm.APIConnectionError,
|
|
litellm.RateLimitError,
|
|
]
|
|
return create_base_retry_decorator(
|
|
error_types=errors, max_retries=llm.max_retries, run_manager=run_manager
|
|
)
|
|
|
|
|
|
def _convert_dict_to_message(_dict: Mapping[str, Any]) -> BaseMessage:
|
|
role = _dict["role"]
|
|
if role == "user":
|
|
return HumanMessage(content=_dict["content"])
|
|
elif role == "assistant":
|
|
# Fix for azure
|
|
# Also OpenAI returns None for tool invocations
|
|
content = _dict.get("content", "") or ""
|
|
|
|
additional_kwargs = {}
|
|
if _dict.get("function_call"):
|
|
additional_kwargs["function_call"] = dict(_dict["function_call"])
|
|
|
|
if _dict.get("tool_calls"):
|
|
additional_kwargs["tool_calls"] = _dict["tool_calls"]
|
|
|
|
return AIMessage(content=content, additional_kwargs=additional_kwargs)
|
|
elif role == "system":
|
|
return SystemMessage(content=_dict["content"])
|
|
elif role == "function":
|
|
return FunctionMessage(content=_dict["content"], name=_dict["name"])
|
|
else:
|
|
return ChatMessage(content=_dict["content"], role=role)
|
|
|
|
|
|
async def acompletion_with_retry(
|
|
llm: ChatLiteLLM,
|
|
run_manager: Optional[AsyncCallbackManagerForLLMRun] = None,
|
|
**kwargs: Any,
|
|
) -> Any:
|
|
"""Use tenacity to retry the async completion call."""
|
|
retry_decorator = _create_retry_decorator(llm, run_manager=run_manager)
|
|
|
|
@retry_decorator
|
|
async def _completion_with_retry(**kwargs: Any) -> Any:
|
|
# Use OpenAI's async api https://github.com/openai/openai-python#async-api
|
|
return await llm.client.acreate(**kwargs)
|
|
|
|
return await _completion_with_retry(**kwargs)
|
|
|
|
|
|
def _convert_delta_to_message_chunk(
|
|
_dict: Mapping[str, Any], default_class: Type[BaseMessageChunk]
|
|
) -> BaseMessageChunk:
|
|
role = _dict.get("role")
|
|
content = _dict.get("content") or ""
|
|
if _dict.get("function_call"):
|
|
additional_kwargs = {"function_call": dict(_dict["function_call"])}
|
|
else:
|
|
additional_kwargs = {}
|
|
|
|
tool_call_chunks = []
|
|
if raw_tool_calls := _dict.get("tool_calls"):
|
|
additional_kwargs["tool_calls"] = raw_tool_calls
|
|
try:
|
|
tool_call_chunks = [
|
|
ToolCallChunk(
|
|
name=rtc["function"].get("name"),
|
|
args=rtc["function"].get("arguments"),
|
|
id=rtc.get("id"),
|
|
index=rtc["index"],
|
|
)
|
|
for rtc in raw_tool_calls
|
|
]
|
|
except KeyError:
|
|
pass
|
|
|
|
if role == "user" or default_class == HumanMessageChunk:
|
|
return HumanMessageChunk(content=content)
|
|
elif role == "assistant" or default_class == AIMessageChunk:
|
|
return AIMessageChunk(
|
|
content=content,
|
|
additional_kwargs=additional_kwargs,
|
|
tool_call_chunks=tool_call_chunks,
|
|
)
|
|
elif role == "system" or default_class == SystemMessageChunk:
|
|
return SystemMessageChunk(content=content)
|
|
elif role == "function" or default_class == FunctionMessageChunk:
|
|
return FunctionMessageChunk(content=content, name=_dict["name"])
|
|
elif role or default_class == ChatMessageChunk:
|
|
return ChatMessageChunk(content=content, role=role) # type: ignore[arg-type]
|
|
else:
|
|
return default_class(content=content) # type: ignore[call-arg]
|
|
|
|
|
|
def _lc_tool_call_to_openai_tool_call(tool_call: ToolCall) -> dict:
|
|
return {
|
|
"type": "function",
|
|
"id": tool_call["id"],
|
|
"function": {
|
|
"name": tool_call["name"],
|
|
"arguments": json.dumps(tool_call["args"]),
|
|
},
|
|
}
|
|
|
|
|
|
def _convert_message_to_dict(message: BaseMessage) -> dict:
|
|
message_dict: Dict[str, Any] = {"content": message.content}
|
|
if isinstance(message, ChatMessage):
|
|
message_dict["role"] = message.role
|
|
elif isinstance(message, HumanMessage):
|
|
message_dict["role"] = "user"
|
|
elif isinstance(message, AIMessage):
|
|
message_dict["role"] = "assistant"
|
|
if "function_call" in message.additional_kwargs:
|
|
message_dict["function_call"] = message.additional_kwargs["function_call"]
|
|
if message.tool_calls:
|
|
message_dict["tool_calls"] = [
|
|
_lc_tool_call_to_openai_tool_call(tc) for tc in message.tool_calls
|
|
]
|
|
elif "tool_calls" in message.additional_kwargs:
|
|
message_dict["tool_calls"] = message.additional_kwargs["tool_calls"]
|
|
elif isinstance(message, SystemMessage):
|
|
message_dict["role"] = "system"
|
|
elif isinstance(message, FunctionMessage):
|
|
message_dict["role"] = "function"
|
|
message_dict["name"] = message.name
|
|
elif isinstance(message, ToolMessage):
|
|
message_dict["role"] = "tool"
|
|
message_dict["tool_call_id"] = message.tool_call_id
|
|
else:
|
|
raise ValueError(f"Got unknown type {message}")
|
|
if "name" in message.additional_kwargs:
|
|
message_dict["name"] = message.additional_kwargs["name"]
|
|
return message_dict
|
|
|
|
|
|
class ChatLiteLLM(BaseChatModel):
|
|
"""Chat model that uses the LiteLLM API."""
|
|
|
|
client: Any #: :meta private:
|
|
model: str = "gpt-3.5-turbo"
|
|
model_name: Optional[str] = None
|
|
"""Model name to use."""
|
|
openai_api_key: Optional[str] = None
|
|
azure_api_key: Optional[str] = None
|
|
anthropic_api_key: Optional[str] = None
|
|
replicate_api_key: Optional[str] = None
|
|
cohere_api_key: Optional[str] = None
|
|
openrouter_api_key: Optional[str] = None
|
|
streaming: bool = False
|
|
api_base: Optional[str] = None
|
|
organization: Optional[str] = None
|
|
custom_llm_provider: Optional[str] = None
|
|
request_timeout: Optional[Union[float, Tuple[float, float]]] = None
|
|
temperature: Optional[float] = 1
|
|
model_kwargs: Dict[str, Any] = Field(default_factory=dict)
|
|
"""Run inference with this temperature. Must be in the closed
|
|
interval [0.0, 1.0]."""
|
|
top_p: Optional[float] = None
|
|
"""Decode using nucleus sampling: consider the smallest set of tokens whose
|
|
probability sum is at least top_p. Must be in the closed interval [0.0, 1.0]."""
|
|
top_k: Optional[int] = None
|
|
"""Decode using top-k sampling: consider the set of top_k most probable tokens.
|
|
Must be positive."""
|
|
n: int = 1
|
|
"""Number of chat completions to generate for each prompt. Note that the API may
|
|
not return the full n completions if duplicates are generated."""
|
|
max_tokens: Optional[int] = None
|
|
|
|
max_retries: int = 6
|
|
|
|
@property
|
|
def _default_params(self) -> Dict[str, Any]:
|
|
"""Get the default parameters for calling OpenAI API."""
|
|
set_model_value = self.model
|
|
if self.model_name is not None:
|
|
set_model_value = self.model_name
|
|
return {
|
|
"model": set_model_value,
|
|
"force_timeout": self.request_timeout,
|
|
"max_tokens": self.max_tokens,
|
|
"stream": self.streaming,
|
|
"n": self.n,
|
|
"temperature": self.temperature,
|
|
"custom_llm_provider": self.custom_llm_provider,
|
|
**self.model_kwargs,
|
|
}
|
|
|
|
@property
|
|
def _client_params(self) -> Dict[str, Any]:
|
|
"""Get the parameters used for the openai client."""
|
|
set_model_value = self.model
|
|
if self.model_name is not None:
|
|
set_model_value = self.model_name
|
|
self.client.api_base = self.api_base
|
|
self.client.organization = self.organization
|
|
creds: Dict[str, Any] = {
|
|
"model": set_model_value,
|
|
"force_timeout": self.request_timeout,
|
|
"api_base": self.api_base,
|
|
}
|
|
return {**self._default_params, **creds}
|
|
|
|
def completion_with_retry(
|
|
self, run_manager: Optional[CallbackManagerForLLMRun] = None, **kwargs: Any
|
|
) -> Any:
|
|
"""Use tenacity to retry the completion call."""
|
|
retry_decorator = _create_retry_decorator(self, run_manager=run_manager)
|
|
|
|
@retry_decorator
|
|
def _completion_with_retry(**kwargs: Any) -> Any:
|
|
return self.client.completion(**kwargs)
|
|
|
|
return _completion_with_retry(**kwargs)
|
|
|
|
@pre_init
|
|
def validate_environment(cls, values: Dict) -> Dict:
|
|
"""Validate api key, python package exists, temperature, top_p, and top_k."""
|
|
try:
|
|
import litellm
|
|
except ImportError:
|
|
raise ChatLiteLLMException(
|
|
"Could not import litellm python package. "
|
|
"Please install it with `pip install litellm`"
|
|
)
|
|
|
|
values["openai_api_key"] = get_from_dict_or_env(
|
|
values, "openai_api_key", "OPENAI_API_KEY", default=""
|
|
)
|
|
values["azure_api_key"] = get_from_dict_or_env(
|
|
values, "azure_api_key", "AZURE_API_KEY", default=""
|
|
)
|
|
values["anthropic_api_key"] = get_from_dict_or_env(
|
|
values, "anthropic_api_key", "ANTHROPIC_API_KEY", default=""
|
|
)
|
|
values["replicate_api_key"] = get_from_dict_or_env(
|
|
values, "replicate_api_key", "REPLICATE_API_KEY", default=""
|
|
)
|
|
values["openrouter_api_key"] = get_from_dict_or_env(
|
|
values, "openrouter_api_key", "OPENROUTER_API_KEY", default=""
|
|
)
|
|
values["cohere_api_key"] = get_from_dict_or_env(
|
|
values, "cohere_api_key", "COHERE_API_KEY", default=""
|
|
)
|
|
values["huggingface_api_key"] = get_from_dict_or_env(
|
|
values, "huggingface_api_key", "HUGGINGFACE_API_KEY", default=""
|
|
)
|
|
values["together_ai_api_key"] = get_from_dict_or_env(
|
|
values, "together_ai_api_key", "TOGETHERAI_API_KEY", default=""
|
|
)
|
|
values["client"] = litellm
|
|
|
|
if values["temperature"] is not None and not 0 <= values["temperature"] <= 1:
|
|
raise ValueError("temperature must be in the range [0.0, 1.0]")
|
|
|
|
if values["top_p"] is not None and not 0 <= values["top_p"] <= 1:
|
|
raise ValueError("top_p must be in the range [0.0, 1.0]")
|
|
|
|
if values["top_k"] is not None and values["top_k"] <= 0:
|
|
raise ValueError("top_k must be positive")
|
|
|
|
return values
|
|
|
|
def _generate(
|
|
self,
|
|
messages: List[BaseMessage],
|
|
stop: Optional[List[str]] = None,
|
|
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
|
stream: Optional[bool] = None,
|
|
**kwargs: Any,
|
|
) -> ChatResult:
|
|
should_stream = stream if stream is not None else self.streaming
|
|
if should_stream:
|
|
stream_iter = self._stream(
|
|
messages, stop=stop, run_manager=run_manager, **kwargs
|
|
)
|
|
return generate_from_stream(stream_iter)
|
|
|
|
message_dicts, params = self._create_message_dicts(messages, stop)
|
|
params = {**params, **kwargs}
|
|
response = self.completion_with_retry(
|
|
messages=message_dicts, run_manager=run_manager, **params
|
|
)
|
|
return self._create_chat_result(response)
|
|
|
|
def _create_chat_result(self, response: Mapping[str, Any]) -> ChatResult:
|
|
generations = []
|
|
for res in response["choices"]:
|
|
message = _convert_dict_to_message(res["message"])
|
|
gen = ChatGeneration(
|
|
message=message,
|
|
generation_info=dict(finish_reason=res.get("finish_reason")),
|
|
)
|
|
generations.append(gen)
|
|
token_usage = response.get("usage", {})
|
|
set_model_value = self.model
|
|
if self.model_name is not None:
|
|
set_model_value = self.model_name
|
|
llm_output = {"token_usage": token_usage, "model": set_model_value}
|
|
return ChatResult(generations=generations, llm_output=llm_output)
|
|
|
|
def _create_message_dicts(
|
|
self, messages: List[BaseMessage], stop: Optional[List[str]]
|
|
) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]:
|
|
params = self._client_params
|
|
if stop is not None:
|
|
if "stop" in params:
|
|
raise ValueError("`stop` found in both the input and default params.")
|
|
params["stop"] = stop
|
|
message_dicts = [_convert_message_to_dict(m) for m in messages]
|
|
return message_dicts, params
|
|
|
|
def _stream(
|
|
self,
|
|
messages: List[BaseMessage],
|
|
stop: Optional[List[str]] = None,
|
|
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
|
**kwargs: Any,
|
|
) -> Iterator[ChatGenerationChunk]:
|
|
message_dicts, params = self._create_message_dicts(messages, stop)
|
|
params = {**params, **kwargs, "stream": True}
|
|
|
|
default_chunk_class = AIMessageChunk
|
|
for chunk in self.completion_with_retry(
|
|
messages=message_dicts, run_manager=run_manager, **params
|
|
):
|
|
if not isinstance(chunk, dict):
|
|
chunk = chunk.model_dump()
|
|
if len(chunk["choices"]) == 0:
|
|
continue
|
|
delta = chunk["choices"][0]["delta"]
|
|
chunk = _convert_delta_to_message_chunk(delta, default_chunk_class)
|
|
default_chunk_class = chunk.__class__
|
|
cg_chunk = ChatGenerationChunk(message=chunk)
|
|
if run_manager:
|
|
run_manager.on_llm_new_token(chunk.content, chunk=cg_chunk)
|
|
yield cg_chunk
|
|
|
|
async def _astream(
|
|
self,
|
|
messages: List[BaseMessage],
|
|
stop: Optional[List[str]] = None,
|
|
run_manager: Optional[AsyncCallbackManagerForLLMRun] = None,
|
|
**kwargs: Any,
|
|
) -> AsyncIterator[ChatGenerationChunk]:
|
|
message_dicts, params = self._create_message_dicts(messages, stop)
|
|
params = {**params, **kwargs, "stream": True}
|
|
|
|
default_chunk_class = AIMessageChunk
|
|
async for chunk in await acompletion_with_retry(
|
|
self, messages=message_dicts, run_manager=run_manager, **params
|
|
):
|
|
if not isinstance(chunk, dict):
|
|
chunk = chunk.model_dump()
|
|
if len(chunk["choices"]) == 0:
|
|
continue
|
|
delta = chunk["choices"][0]["delta"]
|
|
chunk = _convert_delta_to_message_chunk(delta, default_chunk_class)
|
|
default_chunk_class = chunk.__class__
|
|
cg_chunk = ChatGenerationChunk(message=chunk)
|
|
if run_manager:
|
|
await run_manager.on_llm_new_token(chunk.content, chunk=cg_chunk)
|
|
yield cg_chunk
|
|
|
|
async def _agenerate(
|
|
self,
|
|
messages: List[BaseMessage],
|
|
stop: Optional[List[str]] = None,
|
|
run_manager: Optional[AsyncCallbackManagerForLLMRun] = None,
|
|
stream: Optional[bool] = None,
|
|
**kwargs: Any,
|
|
) -> ChatResult:
|
|
should_stream = stream if stream is not None else self.streaming
|
|
if should_stream:
|
|
stream_iter = self._astream(
|
|
messages=messages, stop=stop, run_manager=run_manager, **kwargs
|
|
)
|
|
return await agenerate_from_stream(stream_iter)
|
|
|
|
message_dicts, params = self._create_message_dicts(messages, stop)
|
|
params = {**params, **kwargs}
|
|
response = await acompletion_with_retry(
|
|
self, messages=message_dicts, run_manager=run_manager, **params
|
|
)
|
|
return self._create_chat_result(response)
|
|
|
|
def bind_tools(
|
|
self,
|
|
tools: Sequence[Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]],
|
|
**kwargs: Any,
|
|
) -> Runnable[LanguageModelInput, BaseMessage]:
|
|
"""Bind tool-like objects to this chat model.
|
|
|
|
LiteLLM expects tools argument in OpenAI format.
|
|
|
|
Args:
|
|
tools: A list of tool definitions to bind to this chat model.
|
|
Can be a dictionary, pydantic model, callable, or BaseTool. Pydantic
|
|
models, callables, and BaseTools will be automatically converted to
|
|
their schema dictionary representation.
|
|
tool_choice: Which tool to require the model to call.
|
|
Must be the name of the single provided function or
|
|
"auto" to automatically determine which function to call
|
|
(if any), or a dict of the form:
|
|
{"type": "function", "function": {"name": <<tool_name>>}}.
|
|
**kwargs: Any additional parameters to pass to the
|
|
:class:`~langchain.runnable.Runnable` constructor.
|
|
"""
|
|
|
|
formatted_tools = [convert_to_openai_tool(tool) for tool in tools]
|
|
return super().bind(tools=formatted_tools, **kwargs)
|
|
|
|
@property
|
|
def _identifying_params(self) -> Dict[str, Any]:
|
|
"""Get the identifying parameters."""
|
|
set_model_value = self.model
|
|
if self.model_name is not None:
|
|
set_model_value = self.model_name
|
|
return {
|
|
"model": set_model_value,
|
|
"temperature": self.temperature,
|
|
"top_p": self.top_p,
|
|
"top_k": self.top_k,
|
|
"n": self.n,
|
|
}
|
|
|
|
@property
|
|
def _llm_type(self) -> str:
|
|
return "litellm-chat"
|