summaryrefslogtreecommitdiffstats
path: root/g4f/gui/server
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/gui/server')
-rw-r--r--g4f/gui/server/api.py13
-rw-r--r--g4f/gui/server/js_api.py1
-rw-r--r--g4f/gui/server/website.py12
3 files changed, 16 insertions, 10 deletions
diff --git a/g4f/gui/server/api.py b/g4f/gui/server/api.py
index 7c09fdbe..2b3f2fb6 100644
--- a/g4f/gui/server/api.py
+++ b/g4f/gui/server/api.py
@@ -80,13 +80,12 @@ class Api():
Returns:
dict: Arguments prepared for chat completion.
"""
- provider = json_data.get('provider', None)
- if "image" in kwargs and provider is None:
- provider = "Bing"
- if provider == 'OpenaiChat':
- kwargs['auto_continue'] = True
-
+ model = json_data.get('model') or models.default
+ provider = json_data.get('provider')
messages = json_data['messages']
+ api_key = json_data.get("api_key")
+ if api_key is not None:
+ kwargs["api_key"] = api_key
if json_data.get('web_search'):
if provider == "Bing":
kwargs['web_search'] = True
@@ -98,8 +97,6 @@ class Api():
if conversation_id and provider in conversations and conversation_id in conversations[provider]:
kwargs["conversation"] = conversations[provider][conversation_id]
- model = json_data.get('model') or models.default
-
return {
"model": model,
"provider": provider,
diff --git a/g4f/gui/server/js_api.py b/g4f/gui/server/js_api.py
index e5550f27..08eed947 100644
--- a/g4f/gui/server/js_api.py
+++ b/g4f/gui/server/js_api.py
@@ -1,6 +1,5 @@
from __future__ import annotations
-import logging
import json
import os.path
from typing import Iterator
diff --git a/g4f/gui/server/website.py b/g4f/gui/server/website.py
index 4e611177..5e633674 100644
--- a/g4f/gui/server/website.py
+++ b/g4f/gui/server/website.py
@@ -4,9 +4,11 @@ from flask import render_template, redirect
class Website:
def __init__(self, app) -> None:
self.app = app
+ def redirect_home():
+ return redirect('/chat')
self.routes = {
'/': {
- 'function': lambda: redirect('/chat'),
+ 'function': redirect_home,
'methods': ['GET', 'POST']
},
'/chat/': {
@@ -17,6 +19,14 @@ class Website:
'function': self._chat,
'methods': ['GET', 'POST']
},
+ '/menu/': {
+ 'function': redirect_home,
+ 'methods': ['GET', 'POST']
+ },
+ '/settings/': {
+ 'function': redirect_home,
+ 'methods': ['GET', 'POST']
+ },
}
def _chat(self, conversation_id):