Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
import json
|
|
import os
|
|
import yaml
|
|
import requests
|
|
import pathlib
|
|
from aiohttp import web
|
|
|
|
root_path = pathlib.Path(__file__).parent.parent.parent.parent
|
|
config_path = os.path.join(root_path,'config.yaml')
|
|
class FluxAIAPI:
|
|
def __init__(self):
|
|
self.api_url = "https://fluxaiimagegenerator.com/api"
|
|
self.origin = "https://fluxaiimagegenerator.com"
|
|
self.user_agent = None
|
|
self.cookie = None
|
|
|
|
def promptGenerate(self, text, cookies=None):
|
|
cookie = self.cookie if cookies is None else cookies
|
|
if cookie is None:
|
|
if os.path.isfile(config_path):
|
|
with open(config_path, 'r') as f:
|
|
data = yaml.load(f, Loader=yaml.FullLoader)
|
|
if 'FLUXAI_COOKIE' not in data:
|
|
raise Exception("Please add FLUXAI_COOKIE to config.yaml")
|
|
if "FLUXAI_USER_AGENT" in data:
|
|
self.user_agent = data["FLUXAI_USER_AGENT"]
|
|
self.cookie = cookie = data['FLUXAI_COOKIE']
|
|
|
|
headers = {
|
|
"Cookie": cookie,
|
|
"Referer": "https://fluxaiimagegenerator.com/flux-prompt-generator",
|
|
"Origin": self.origin,
|
|
"Content-Type": "application/json",
|
|
}
|
|
if self.user_agent is not None:
|
|
headers['User-Agent'] = self.user_agent
|
|
|
|
url = self.api_url + '/prompt'
|
|
json = {
|
|
"prompt": text
|
|
}
|
|
|
|
response = requests.post(url, json=json, headers=headers)
|
|
res = response.json()
|
|
if "error" in res:
|
|
return res['error']
|
|
elif "data" in res and "prompt" in res['data']:
|
|
return res['data']['prompt']
|
|
|
|
fluxaiAPI = FluxAIAPI()
|
|
|