Skip to content

Instantly share code, notes, and snippets.

@olebedev
Last active April 9, 2025 11:29
Show Gist options
  • Select an option

  • Save olebedev/b87f1f573be817530f2254b43ea936dc to your computer and use it in GitHub Desktop.

Select an option

Save olebedev/b87f1f573be817530f2254b43ea936dc to your computer and use it in GitHub Desktop.

Revisions

  1. olebedev created this gist Sep 18, 2024.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ### Installation

    ```bash
    nix-env -i -f ./default.nix
    ```
    19 changes: 19 additions & 0 deletions default.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    with import
    (fetchTarball "https://github.com/NixOS/nixpkgs/archive/8f75dd40856dc79cd07f92270ae3f64a1f4b9de2.tar.gz")
    { };

    # Update LLM package to version 0.16 with o1-preview support.
    # https://github.com/NixOS/nixpkgs/commit/8f75dd40856dc79cd07f92270ae3f64a1f4b9de2


    let
    llmClaude3 = python3Packages.callPackage ./llm-claude-3.nix { };
    pyWithPackages = (python3.withPackages (py: [
    py.llm
    llmClaude3
    ]));
    in
    runCommand "llm" { } ''
    mkdir -p $out/bin
    ln -s ${pyWithPackages}/bin/llm $out/bin/llm
    ''
    93 changes: 93 additions & 0 deletions llm-claude-3.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,93 @@
    { lib
    , buildPythonPackage
    , fetchPypi
    , pythonOlder
    , requests
    , pydantic
    , typing-extensions
    , anthropic
    , poetry-core
    , flit-core
    , setuptools
    , llm
    }:

    let
    llm-claude = buildPythonPackage rec {
    pname = "llm-claude";
    version = "0.4.0"; # Update this to the latest version
    format = "pyproject";

    buildInputs = [
    setuptools
    poetry-core
    flit-core
    llm
    ];
    POETRY_CORE = "${poetry-core}/lib/python3.9/site-packages/poetry/core";

    src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-VyLWJoPKQDuirQ/iDDNYCvo/tbWSVqx3DkTbMTU4X2w=";
    };

    propagatedBuildInputs = [
    anthropic

    ];

    # Add any necessary build inputs or test inputs

    pythonImportsCheck = [ "llm_claude" ];

    meta = with lib; {
    description = "Claude plugin for LLM";
    homepage = "https://github.com/simonw/llm-claude";
    # license = licenses.apache20;
    };
    };

    in

    buildPythonPackage rec {
    pname = "llm_claude_3";
    version = "0.4"; # Replace with the actual version
    format = "pyproject";

    buildInputs = [
    setuptools
    poetry-core
    flit-core
    llm
    ];
    POETRY_CORE = "${poetry-core}/lib/python3.9/site-packages/poetry/core";


    src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-d12EcFJZIwWRNG3llRlKWLB2vBBnN//7+GYo3tFI3dk="; # Replace with the actual SHA256 hash
    };

    propagatedBuildInputs = [
    anthropic
    llm-claude
    ];

    # If there are any build-time dependencies, add them here
    # buildInputs = [ ];

    # If there are any test dependencies, add them here
    # checkInputs = [ ];

    # Disable tests if they're not available or if they're failing
    doCheck = false;

    pythonImportsCheck = [ "llm_claude_3" ];

    meta = with lib; {
    description = "Claude 3 plugin for LLM";
    homepage = "https://pypi.org/project/llm-claude-3/";
    license = licenses.mit; # Replace with the actual license
    maintainers = with maintainers; [ ]; # Add maintainers if applicable
    };
    }