Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flake app to run openai proxy #4612

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ParetoOptimalDev
Copy link

Works with:

nix run .#llama-server-openai-proxy

If merged, then you can run both the server and proxy via two commands:

nix run github:ggerganov/llama.cpp#llama-server
nix run github:ggerganov/llama.cpp#llama-server-openai-proxy

Note: This is likely not ideal or the best way to do this, but it works and can hopefully spark useful discussion to get this feature into the llama.cpp flake 😃

Works with:

nix run .#llama-server-openai-proxy

If merged, then you can run both the server and proxy via two commands:

nix run github:ggerganov/llama.cpp#llama-server
nix run github:ggerganov/llama.cpp#llama-server-openai-proxy
This was referenced Dec 23, 2023
program = "${
(let pythonWithPkgs = pkgs.python3.withPackages (ps: with ps; [ flask requests ]);
in pkgs.writeShellScriptBin "run-openai-proxy" ''
${pythonWithPkgs}/bin/python3 ${self}/examples/server/api_like_OAI.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could've been a makeWrapper. I don't know if api_like_OAI.py takes any command line arguments, but makeWrapper would have passed those on

Comment on lines +116 to +120
(let pythonWithPkgs = pkgs.python3.withPackages (ps: with ps; [ flask requests ]);
in pkgs.writeShellScriptBin "run-openai-proxy" ''
${pythonWithPkgs}/bin/python3 ${self}/examples/server/api_like_OAI.py
'')
}/bin/run-openai-proxy";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't suggest anything concrete right now, but it might be a good thing to do some form of buildPythonApplication because its probably less affected by PYTHONPATH contamination.

@@ -110,6 +110,15 @@
type = "app";
program = "${self.packages.${system}.default}/bin/llama-server";
};
apps.llama-server-openai-proxy = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to mention this in #4605, but we wouldn't have had to manually wrap these in apps if we instead exposed them (in the overlay and) in packages/legacyPackages, and if we ensured that meta.mainPrograms are set correctly (with writeShellScriptBin they are)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could now add this to scope.nix:

lib.makeScope newScope (
self: {
inherit llamaVersion;
llama-cpp = self.callPackage ./package.nix { };
}
)

This way the attribute would show up as llamaPackages.llama-server-openai-proxy in nixpkgs with the flake's overlays.default applied, as well as in the flake's legacyPackages.${system}.llamaPackages.

@SomeoneSerge SomeoneSerge added the nix Issues specific to consuming flake.nix, or generally concerned with ❄ Nix-based llama.cpp deployment label Dec 31, 2023
@ParetoOptimalDev
Copy link
Author

I think this might not be needed since the default llama-server started on port 8080 seems to be openai compatible.

@ggerganov
Copy link
Owner

I think this might not be needed since the default llama-server started on port 8080 seems to be openai compatible.

Yes, I'm thinking we should probably deprecate examples/server/api_like_OAI.py and improve the built-in server support for the OpenAI API (#4216)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nix Issues specific to consuming flake.nix, or generally concerned with ❄ Nix-based llama.cpp deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants