Update api/config.py
Browse files- api/config.py +30 -69
api/config.py
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
|
| 4 |
load_dotenv()
|
| 5 |
|
| 6 |
-
# Base URL and
|
| 7 |
-
BASE_URL = "https://app.giz.ai
|
|
|
|
|
|
|
| 8 |
common_headers = {
|
| 9 |
'Accept': 'application/json, text/plain, */*',
|
| 10 |
'Accept-Language': 'en-US,en;q=0.9',
|
| 11 |
'Cache-Control': 'no-cache',
|
| 12 |
-
'
|
| 13 |
-
'Content-Type': 'application/json',
|
| 14 |
-
'Origin': 'https://app.giz.ai',
|
| 15 |
'Pragma': 'no-cache',
|
| 16 |
'Sec-Fetch-Dest': 'empty',
|
| 17 |
'Sec-Fetch-Mode': 'cors',
|
|
@@ -19,32 +21,19 @@ common_headers = {
|
|
| 19 |
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
| 20 |
'sec-ch-ua': '"Not?A_Brand";v="99", "Chromium";v="130"',
|
| 21 |
'sec-ch-ua-mobile': '?0',
|
| 22 |
-
'sec-ch-ua-platform': '"Linux"'
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
-
# Header Configurations for
|
| 26 |
-
def get_headers_api_chat(referer_url):
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
return
|
| 31 |
-
**common_headers,
|
| 32 |
-
'Accept': 'text/x-component',
|
| 33 |
-
'Content-Type': 'text/plain;charset=UTF-8',
|
| 34 |
-
'Referer': chat_url,
|
| 35 |
-
'next-action': next_action,
|
| 36 |
-
'next-router-state-tree': next_router_state_tree,
|
| 37 |
-
'next-url': '/',
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
# Application Secret for Authentication
|
| 41 |
-
APP_SECRET = os.getenv("APP_SECRET")
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
# Supported Chat Models
|
| 47 |
-
chat_models = [
|
| 48 |
'chat-gemini-flash',
|
| 49 |
'chat-gemini-pro',
|
| 50 |
'chat-gpt4m',
|
|
@@ -57,19 +46,16 @@ chat_models = [
|
|
| 57 |
'chat-o1-mini'
|
| 58 |
]
|
| 59 |
|
| 60 |
-
|
| 61 |
-
image_models = [
|
| 62 |
'flux1',
|
| 63 |
'sdxl',
|
| 64 |
'sd',
|
| 65 |
'sd35',
|
| 66 |
]
|
| 67 |
|
| 68 |
-
|
| 69 |
-
models = [*chat_models, *image_models]
|
| 70 |
|
| 71 |
-
|
| 72 |
-
model_aliases = {
|
| 73 |
# Chat model aliases
|
| 74 |
"gemini-flash": "chat-gemini-flash",
|
| 75 |
"gemini-pro": "chat-gemini-pro",
|
|
@@ -86,40 +72,15 @@ model_aliases = {
|
|
| 86 |
"flux-schnell": "flux1",
|
| 87 |
}
|
| 88 |
|
| 89 |
-
|
| 90 |
-
ALLOWED_MODELS = [
|
| 91 |
-
{"id": "chat-gemini-flash", "name": "Chat Gemini Flash"},
|
| 92 |
-
{"id": "chat-gemini-pro", "name": "Chat Gemini Pro"},
|
| 93 |
-
{"id": "chat-gpt4m", "name": "Chat GPT-4m"},
|
| 94 |
-
{"id": "chat-gpt4", "name": "Chat GPT-4"},
|
| 95 |
-
{"id": "claude-sonnet", "name": "Claude Sonnet"},
|
| 96 |
-
{"id": "claude-haiku", "name": "Claude Haiku"},
|
| 97 |
-
{"id": "llama-3-70b", "name": "LLaMA 3-70B"},
|
| 98 |
-
{"id": "llama-3-8b", "name": "LLaMA 3-8B"},
|
| 99 |
-
{"id": "mistral-large", "name": "Mistral Large"},
|
| 100 |
-
{"id": "chat-o1-mini", "name": "Chat O1 Mini"},
|
| 101 |
-
{"id": "flux1", "name": "Flux1"},
|
| 102 |
-
{"id": "sdxl", "name": "SDXL"},
|
| 103 |
-
{"id": "sd", "name": "SD"},
|
| 104 |
-
{"id": "sd35", "name": "SD35"},
|
| 105 |
-
]
|
| 106 |
|
| 107 |
-
|
| 108 |
-
MODEL_MAPPING
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
"chat-gpt4m": "chat-gpt4m",
|
| 112 |
-
"chat-gpt4": "chat-gpt4",
|
| 113 |
-
"claude-sonnet": "claude-sonnet",
|
| 114 |
-
"claude-haiku": "claude-haiku",
|
| 115 |
-
"llama-3-70b": "llama-3-70b",
|
| 116 |
-
"llama-3-8b": "llama-3-8b",
|
| 117 |
-
"mistral-large": "mistral-large",
|
| 118 |
-
"chat-o1-mini": "chat-o1-mini",
|
| 119 |
-
"flux1": "flux1",
|
| 120 |
-
"sdxl": "sdxl",
|
| 121 |
-
"sd": "sd",
|
| 122 |
-
"sd35": "sd35",
|
| 123 |
-
}
|
| 124 |
|
| 125 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# api/config.py
|
| 2 |
+
|
| 3 |
import os
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
+
# Base URL and API Endpoint for GizAI
|
| 9 |
+
BASE_URL = "https://app.giz.ai"
|
| 10 |
+
API_ENDPOINT = "https://app.giz.ai/api/data/users/inferenceServer.infer"
|
| 11 |
+
|
| 12 |
common_headers = {
|
| 13 |
'Accept': 'application/json, text/plain, */*',
|
| 14 |
'Accept-Language': 'en-US,en;q=0.9',
|
| 15 |
'Cache-Control': 'no-cache',
|
| 16 |
+
'Origin': BASE_URL,
|
|
|
|
|
|
|
| 17 |
'Pragma': 'no-cache',
|
| 18 |
'Sec-Fetch-Dest': 'empty',
|
| 19 |
'Sec-Fetch-Mode': 'cors',
|
|
|
|
| 21 |
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
| 22 |
'sec-ch-ua': '"Not?A_Brand";v="99", "Chromium";v="130"',
|
| 23 |
'sec-ch-ua-mobile': '?0',
|
| 24 |
+
'sec-ch-ua-platform': '"Linux"',
|
| 25 |
+
'Content-Type': 'application/json'
|
| 26 |
}
|
| 27 |
|
| 28 |
+
# Header Configurations for Specific API Calls
|
| 29 |
+
def get_headers_api_chat(referer_url=None):
|
| 30 |
+
headers = common_headers.copy()
|
| 31 |
+
if referer_url:
|
| 32 |
+
headers['Referer'] = referer_url
|
| 33 |
+
return headers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
# Define GizAI Models
|
| 36 |
+
CHAT_MODELS = [
|
|
|
|
|
|
|
|
|
|
| 37 |
'chat-gemini-flash',
|
| 38 |
'chat-gemini-pro',
|
| 39 |
'chat-gpt4m',
|
|
|
|
| 46 |
'chat-o1-mini'
|
| 47 |
]
|
| 48 |
|
| 49 |
+
IMAGE_MODELS = [
|
|
|
|
| 50 |
'flux1',
|
| 51 |
'sdxl',
|
| 52 |
'sd',
|
| 53 |
'sd35',
|
| 54 |
]
|
| 55 |
|
| 56 |
+
MODELS = CHAT_MODELS + IMAGE_MODELS
|
|
|
|
| 57 |
|
| 58 |
+
MODEL_ALIASES = {
|
|
|
|
| 59 |
# Chat model aliases
|
| 60 |
"gemini-flash": "chat-gemini-flash",
|
| 61 |
"gemini-pro": "chat-gemini-pro",
|
|
|
|
| 72 |
"flux-schnell": "flux1",
|
| 73 |
}
|
| 74 |
|
| 75 |
+
DEFAULT_MODEL = 'chat-gemini-flash'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
MODEL_MAPPING = {model: model for model in MODELS}
|
| 78 |
+
MODEL_MAPPING.update(MODEL_ALIASES)
|
| 79 |
+
|
| 80 |
+
ALLOWED_MODELS = MODELS # You can adjust this if you want to restrict further
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
+
# If GizAI requires any agent modes or other configurations, add them here
|
| 83 |
+
AGENT_MODE = {}
|
| 84 |
+
TRENDING_AGENT_MODE = {}
|
| 85 |
+
MODEL_PREFIXES = {}
|
| 86 |
+
MODEL_REFERERS = {}
|