Skip to content

Commit

Permalink
Fix image generation, add new image models (#149)
Browse files Browse the repository at this point in the history
Fixed the Nexra provider. They had changed their API.
Also added the **Flux** and **Midjourney** models.

fixes #94, fixes #117
  • Loading branch information
XInTheDark authored Nov 11, 2024
1 parent aba5e6e commit ccf570b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
"@raycast/api": "^1.80.0",
"duck-duck-scrape": "^2.2.5",
"fetch-to-curl": "^0.6.0",
"g4f-image": "^1.2.0",
"g4f-image": "^1.3.3",
"gemini-g4f": "^12.3.10-beta.1",
"lodash.throttle": "^4.1.1",
"node-fetch": "^3.3.2",
Expand Down
16 changes: 13 additions & 3 deletions src/genImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import fs from "fs";
import fetch from "node-fetch";

import { Storage } from "./api/storage.js";
import { Preferences } from "./api/preferences.js";
import { formatDate, getSupportPath } from "./helpers/helper.js";
import { help_action } from "./helpers/helpPage.jsx";

Expand All @@ -37,6 +38,12 @@ const image_providers = {
samplingMethod: "DPM++ 2M Karras",
},
},
NexraFlux: {
model: "flux",
},
NexraMidjourney: {
model: "midjourney",
},
DeepInfraFlux1Dev: {
model: "black-forest-labs/FLUX-1-dev",
data: {
Expand Down Expand Up @@ -68,6 +75,8 @@ const image_providers = {
const provider_map = {
Prodia: provider.Nexra,
ProdiaStableDiffusion: provider.Nexra,
NexraFlux: provider.Nexra,
NexraMidjourney: provider.Nexra,
DeepInfraFlux1Dev: provider.DeepInfra,
DeepInfraFlux1Schnell: provider.DeepInfra,
StableDiffusionLite: provider.Nexra,
Expand All @@ -80,7 +89,7 @@ const provider_map = {
const default_models = {
Prodia: "ICantBelieveItsNotPhotography_seco.safetensors [4e7a3dfd]",
ProdiaStableDiffusion: "neverendingDream_v122.safetensors [f964ceeb]",
Rocks: "flux",
Rocks: "flux-4o",
};

const defaultImageProvider = "Prodia";
Expand Down Expand Up @@ -152,7 +161,7 @@ export default function genImage() {

try {
const [provider, options] = loadImageOptions(currentChat);
const base64Image = await generate(query, provider, options, { fetch: fetch });
const base64Image = await generate(query, provider, options, { fetch: fetch, debug: Preferences["devMode"] });

// save image
let imagePath = "";
Expand Down Expand Up @@ -240,6 +249,8 @@ export default function genImage() {
<Form.Dropdown id="provider" defaultValue="Prodia">
<Form.Dropdown.Item title="Prodia" value="Prodia" />
<Form.Dropdown.Item title="ProdiaStableDiffusion" value="ProdiaStableDiffusion" />
<Form.Dropdown.Item title="Nexra FLUX" value="NexraFlux" />
<Form.Dropdown.Item title="Nexra Midjourney" value="NexraMidjourney" />
<Form.Dropdown.Item title="DeepInfra FLUX.1 Dev" value="DeepInfraFlux1Dev" />
<Form.Dropdown.Item title="DeepInfra FLUX.1 Schnell" value="DeepInfraFlux1Schnell" />
<Form.Dropdown.Item title="StableDiffusionLite" value="StableDiffusionLite" />
Expand Down Expand Up @@ -678,7 +689,6 @@ const loadImageOptions = (currentChat) => {

let model = !modelString || modelString === "default" ? default_models[providerString] : modelString;
if (model) {
options.model = model;
data = { ...data, model: model };
}

Expand Down

0 comments on commit ccf570b

Please sign in to comment.