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

Feature Request: Option to specify base URL for server mode #388

Closed
vlasky opened this issue Apr 30, 2024 · 5 comments
Closed

Feature Request: Option to specify base URL for server mode #388

vlasky opened this issue Apr 30, 2024 · 5 comments

Comments

@vlasky
Copy link
Contributor

vlasky commented Apr 30, 2024

I've been testing the use of Nginx as a proxy to serve llamafile under a subdirectory.

i.e. to be able to access the llamafile server via a URL like this:

https://mydomain.com/llamafile/

Llamafile is being launched via systemd under Linux.

I am using a rewrite rule in Nginx to remove the llamafile/ subdirectory in the URL before passing the request to llamafile.

Although I am successfully able to open the index page, it doesn't load correctly because the HTML contains Javascript code that imports the following scripts from the following absolute URLs:

/index.js
/completion.js
/json-schema-to-grammar.mjs

This is a result of the following HTML lines in the index page:

<script type="module">
    import {
      html, h, signal, effect, computed, render, useSignal, useEffect, useRef, Component
    } from '/index.js';

    import { llama } from '/completion.js';
    import { SchemaConverter } from '/json-schema-to-grammar.mjs';

At the moment, llamafile does not have a command line option to specify a base URL or URL subdirectory prefix.

The --path command line option cannot be used for this purpose.

It would be great if a base URL/URL subdirectory prefix command line option could be added to llamafile.

@clyfish
Copy link

clyfish commented Jun 6, 2024

ggerganov/llama.cpp@0642b22#diff-250e89dd8f0b29364f4245b54b512cde3e6d898245953aa7d7da6e61708bde21
@mofosyne We can sync with llama.cpp upstream to fix this issue.

@clyfish
Copy link

clyfish commented Jun 6, 2024

@vlasky Before sync with llama.cpp, we can modify the frontend files and build llamafile ourselves.

sed -i "s# from '/# from './#g" llama.cpp/server/public/index.html
sed -i 's# fetch("/# fetch("./#g' llama.cpp/server/public/completion.js

@vlasky
Copy link
Contributor Author

vlasky commented Oct 23, 2024

I have submitted a PR for this feature:

#597

@vlasky
Copy link
Contributor Author

vlasky commented Oct 28, 2024

I have submitted a PR for this same functionality in llamafiler as well:

#604

@vlasky
Copy link
Contributor Author

vlasky commented Oct 31, 2024

These enhancements have been released in llamafile v0.8.15

@vlasky vlasky closed this as completed Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants