From 0ea720c1db32ce0c7d31e1a0b96a4d7d3d130cc7 Mon Sep 17 00:00:00 2001 From: "alvarosoares01@gmail.com" Date: Wed, 13 Dec 2023 23:16:35 -0300 Subject: Add providers in api --- g4f/api/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'g4f/api') diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index 410fcc5f..a79da7b0 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -84,6 +84,10 @@ class Api: stream = True if item_data.get("stream") == "True" else False messages = item_data.get('messages') conversation = item_data.get('conversation') if item_data.get('conversation') != None else None + provider = item_data.get('provider').replace('g4f.Provider.', '') + provider = provider if provider and provider != "Auto" else None + if provider != None: + provider = g4f.Provider.ProviderUtils.convert.get(provider) try: if model == 'pi': @@ -92,12 +96,14 @@ class Api: stream=stream, messages=messages, conversation=conversation, + provider = provider, ignored=self.list_ignored_providers) else: response = g4f.ChatCompletion.create( model=model, stream=stream, messages=messages, + provider = provider, ignored=self.list_ignored_providers) except Exception as e: logging.exception(e) -- cgit v1.2.3