From 18c835d2547ebfd797e79b5dbcd22d46dc4cb155 Mon Sep 17 00:00:00 2001 From: Jens Rabe Date: Fri, 29 Nov 2024 18:22:48 +0100 Subject: [PATCH] Fix for exo with the model list not being at 'data' endpoint but at the res directly; added flake and envrc for nix-based setups --- .envrc | 1 + .gitignore | 1 + app/utils/constants.ts | 5 +++- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 20 ++++++++++++++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..8392d159f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3303fba9b..531d09afd 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ _worker.bundle Modelfile modelfiles +.direnv \ No newline at end of file diff --git a/app/utils/constants.ts b/app/utils/constants.ts index 17fe9d8af..1a89baf2a 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -320,7 +320,10 @@ async function getOpenAILikeModels(): Promise { }); const res = (await response.json()) as any; - return res.data.map((model: any) => ({ + // When using the OpenAI-compatible endpoint from Exo, the data is not at `res.data` but `res` directly. + const d = res.data ? res.data : res; + + return d.map((model: any) => ({ name: model.id, label: model.id, provider: 'OpenAILike', diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..7e4744465 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1732521221, + "narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..1a1c73bbf --- /dev/null +++ b/flake.nix @@ -0,0 +1,20 @@ +{ + description = "Environment flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem(system: + let pkgs = nixpkgs.legacyPackages.${system}; in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + nodejs_23 + pnpm + ]; + }; + } + ); +} \ No newline at end of file