From 2a29f1b2ac7a3bd3ac40682a4e11908e576e1af0 Mon Sep 17 00:00:00 2001 From: kqlio67 Date: Mon, 11 Nov 2024 21:18:50 +0200 Subject: [PATCH] Update (g4f/Provider/GizAI.py) --- g4f/Provider/GizAI.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/g4f/Provider/GizAI.py b/g4f/Provider/GizAI.py index a5ce0ec26b5..f00b344eae6 100644 --- a/g4f/Provider/GizAI.py +++ b/g4f/Provider/GizAI.py @@ -8,7 +8,7 @@ class GizAI(AsyncGeneratorProvider, ProviderModelMixin): - url = "https://app.giz.ai" + url = "https://app.giz.ai/assistant" api_endpoint = "https://app.giz.ai/api/data/users/inferenceServer.infer" working = True supports_stream = False @@ -46,7 +46,7 @@ async def create_async_generator( 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'DNT': '1', - 'Origin': cls.url, + 'Origin': 'https://app.giz.ai', 'Pragma': 'no-cache', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', @@ -56,16 +56,21 @@ async def create_async_generator( 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"Linux"' } + + prompt = format_prompt(messages) + async with ClientSession(headers=headers) as session: data = { "model": model, "input": { - "messages": messages, + "messages": [{"type": "human", "content": prompt}], "mode": "plan" }, "noStream": True } async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response: - response.raise_for_status() - result = await response.json() - yield result['output'].strip() + if response.status == 201: + result = await response.json() + yield result['output'].strip() + else: + raise Exception(f"Unexpected response status: {response.status}")