mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 15:04:13 +00:00
community[minor]: rename ChatGPTRouter to GPTRouter (#14913)
**Description:**: Rename integration to GPTRouter **Tag maintainer:** @Gupta-Anubhav12 @samanyougarg @sirjan-ws-ext **Twitter handle:** [@SamanyouGarg](https://twitter.com/SamanyouGarg)
This commit is contained in:
committed by
GitHub
parent
992b04e475
commit
425e5e1791
@@ -31,7 +31,7 @@ from langchain_community.chat_models.fake import FakeListChatModel
|
||||
from langchain_community.chat_models.fireworks import ChatFireworks
|
||||
from langchain_community.chat_models.gigachat import GigaChat
|
||||
from langchain_community.chat_models.google_palm import ChatGooglePalm
|
||||
from langchain_community.chat_models.gpt_router import ChatGPTRouter
|
||||
from langchain_community.chat_models.gpt_router import GPTRouter
|
||||
from langchain_community.chat_models.human import HumanInputChatModel
|
||||
from langchain_community.chat_models.hunyuan import ChatHunyuan
|
||||
from langchain_community.chat_models.javelin_ai_gateway import ChatJavelinAIGateway
|
||||
@@ -80,5 +80,5 @@ __all__ = [
|
||||
"ChatHunyuan",
|
||||
"GigaChat",
|
||||
"VolcEngineMaasChat",
|
||||
"ChatGPTRouter",
|
||||
"GPTRouter",
|
||||
]
|
||||
|
@@ -77,7 +77,7 @@ def get_ordered_generation_requests(
|
||||
|
||||
|
||||
def _create_retry_decorator(
|
||||
llm: ChatGPTRouter,
|
||||
llm: GPTRouter,
|
||||
run_manager: Optional[
|
||||
Union[AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun]
|
||||
] = None,
|
||||
@@ -96,7 +96,7 @@ def _create_retry_decorator(
|
||||
|
||||
|
||||
def completion_with_retry(
|
||||
llm: ChatGPTRouter,
|
||||
llm: GPTRouter,
|
||||
models_priority_list: List[GPTRouterModel],
|
||||
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
||||
**kwargs: Any,
|
||||
@@ -118,7 +118,7 @@ def completion_with_retry(
|
||||
|
||||
|
||||
async def acompletion_with_retry(
|
||||
llm: ChatGPTRouter,
|
||||
llm: GPTRouter,
|
||||
models_priority_list: List[GPTRouterModel],
|
||||
run_manager: Optional[AsyncCallbackManagerForLLMRun] = None,
|
||||
**kwargs: Any,
|
||||
@@ -140,7 +140,7 @@ async def acompletion_with_retry(
|
||||
return await _completion_with_retry(**kwargs)
|
||||
|
||||
|
||||
class ChatGPTRouter(BaseChatModel):
|
||||
class GPTRouter(BaseChatModel):
|
||||
"""GPTRouter by Writesonic Inc.
|
||||
|
||||
For more information, see https://gpt-router.writesonic.com/docs
|
||||
|
@@ -8,7 +8,7 @@ from langchain_core.callbacks import (
|
||||
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
|
||||
from langchain_core.outputs import ChatGeneration, LLMResult
|
||||
|
||||
from langchain_community.chat_models.gpt_router import ChatGPTRouter, GPTRouterModel
|
||||
from langchain_community.chat_models.gpt_router import GPTRouter, GPTRouterModel
|
||||
from tests.unit_tests.callbacks.fake_callback_handler import FakeCallbackHandler
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ def test_gpt_router_call() -> None:
|
||||
anthropic_claude = GPTRouterModel(
|
||||
name="claude-instant-1.2", provider_name="anthropic"
|
||||
)
|
||||
chat = ChatGPTRouter(models_priority_list=[anthropic_claude])
|
||||
chat = GPTRouter(models_priority_list=[anthropic_claude])
|
||||
message = HumanMessage(content="Hello World")
|
||||
response = chat([message])
|
||||
assert isinstance(response, AIMessage)
|
||||
@@ -29,7 +29,7 @@ def test_gpt_router_call_incorrect_model() -> None:
|
||||
anthropic_claude = GPTRouterModel(
|
||||
name="model_does_not_exist", provider_name="anthropic"
|
||||
)
|
||||
chat = ChatGPTRouter(models_priority_list=[anthropic_claude])
|
||||
chat = GPTRouter(models_priority_list=[anthropic_claude])
|
||||
message = HumanMessage(content="Hello World")
|
||||
with pytest.raises(Exception):
|
||||
chat([message])
|
||||
@@ -40,7 +40,7 @@ def test_gpt_router_generate() -> None:
|
||||
anthropic_claude = GPTRouterModel(
|
||||
name="claude-instant-1.2", provider_name="anthropic"
|
||||
)
|
||||
chat = ChatGPTRouter(models_priority_list=[anthropic_claude])
|
||||
chat = GPTRouter(models_priority_list=[anthropic_claude])
|
||||
chat_messages: List[List[BaseMessage]] = [
|
||||
[HumanMessage(content="If (5 + x = 18), what is x?")]
|
||||
]
|
||||
@@ -59,7 +59,7 @@ def test_gpt_router_streaming() -> None:
|
||||
anthropic_claude = GPTRouterModel(
|
||||
name="claude-instant-1.2", provider_name="anthropic"
|
||||
)
|
||||
chat = ChatGPTRouter(models_priority_list=[anthropic_claude], streaming=True)
|
||||
chat = GPTRouter(models_priority_list=[anthropic_claude], streaming=True)
|
||||
message = HumanMessage(content="Hello")
|
||||
response = chat([message])
|
||||
assert isinstance(response, AIMessage)
|
||||
@@ -73,7 +73,7 @@ def test_gpt_router_streaming_callback() -> None:
|
||||
anthropic_claude = GPTRouterModel(
|
||||
name="claude-instant-1.2", provider_name="anthropic"
|
||||
)
|
||||
chat = ChatGPTRouter(
|
||||
chat = GPTRouter(
|
||||
models_priority_list=[anthropic_claude],
|
||||
streaming=True,
|
||||
callback_manager=callback_manager,
|
||||
|
@@ -31,7 +31,7 @@ EXPECTED_ALL = [
|
||||
"ChatHunyuan",
|
||||
"GigaChat",
|
||||
"VolcEngineMaasChat",
|
||||
"ChatGPTRouter",
|
||||
"GPTRouter",
|
||||
]
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user