From 91feb34054f529c37e10d98d2471c8c0c6780147 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Tue, 23 Jan 2024 19:44:48 +0100 Subject: Add ProviderModelMixin for model selection --- g4f/Provider/Liaobots.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'g4f/Provider/Liaobots.py') diff --git a/g4f/Provider/Liaobots.py b/g4f/Provider/Liaobots.py index 88f0c4ff..5151c115 100644 --- a/g4f/Provider/Liaobots.py +++ b/g4f/Provider/Liaobots.py @@ -5,7 +5,7 @@ import uuid from aiohttp import ClientSession from ..typing import AsyncResult, Messages -from .base_provider import AsyncGeneratorProvider +from .base_provider import AsyncGeneratorProvider, ProviderModelMixin models = { "gpt-4": { @@ -70,13 +70,17 @@ models = { } } - -class Liaobots(AsyncGeneratorProvider): +class Liaobots(AsyncGeneratorProvider, ProviderModelMixin): url = "https://liaobots.site" working = True supports_message_history = True supports_gpt_35_turbo = True supports_gpt_4 = True + default_model = "gpt-3.5-turbo" + models = [m for m in models] + model_aliases = { + "claude-v2": "claude-2" + } _auth_code = None _cookie_jar = None @@ -89,7 +93,6 @@ class Liaobots(AsyncGeneratorProvider): proxy: str = None, **kwargs ) -> AsyncResult: - model = model if model in models else "gpt-3.5-turbo" headers = { "authority": "liaobots.com", "content-type": "application/json", @@ -122,7 +125,7 @@ class Liaobots(AsyncGeneratorProvider): data = { "conversationId": str(uuid.uuid4()), - "model": models[model], + "model": models[cls.get_model(model)], "messages": messages, "key": "", "prompt": kwargs.get("system_message", "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully."), -- cgit v1.2.3