2024-02-12 19:58:12 +00:00
|
|
|
# mill.py, Markdown interface for llama.cpp
|
|
|
|
# Copyright (C) 2024 unworriedsafari <unworriedsafari@tilde.club>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
|
|
|
|
|
|
"""
|
2024-02-25 21:33:04 +00:00
|
|
|
# README
|
|
|
|
|
|
|
|
`mill.py v1.1.2`
|
|
|
|
|
|
|
|
Markdown interface for [llama.cpp](//github.com/ggerganov/llama.cpp).
|
|
|
|
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
|
|
1. [Python 3.x](//python.org) (tested on `3.11`)
|
|
|
|
2. [llama.cpp](//github.com/ggerganov/llama.cpp) (tested on `b1860`)
|
|
|
|
|
|
|
|
Developed and tested on Linux. I believe it could also work on Windows or Mac.
|
|
|
|
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
1. Lets you interact with `llama.cpp` using Markdown
|
|
|
|
2. Enables you to use almost every `llama.cpp` option
|
|
|
|
3. Makes no assumptions about what model you want to use
|
|
|
|
4. Lets you change any option at any point in the document
|
|
|
|
5. Caches prompts automatically
|
|
|
|
6. Streams output
|
|
|
|
7. Runs in a CLI environment as well as a CGI environment
|
|
|
|
8. Reads input document from `stdin`, writes output document to `stdout`
|
|
|
|
9. Lets you add support for any other language or LLM through Python modules
|
2024-02-12 19:58:12 +00:00
|
|
|
"""
|
|
|
|
|
2024-02-25 21:33:04 +00:00
|
|
|
import mill, mill_cgi, mill_cli
|
2024-02-12 19:58:12 +00:00
|
|
|
|
|
|
|
|
2024-02-25 21:33:04 +00:00
|
|
|
def print_readme(language, llm_engine):
|
|
|
|
language_mod = mill.load_module(f'lang_{language}')
|
|
|
|
llm_engine_mod = mill.load_module(f'llm_{llm_engine}')
|
|
|
|
|
|
|
|
try:
|
|
|
|
example_mod = mill.load_module(f'example_{language}_{llm_engine}')
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
example_mod = None
|
|
|
|
|
|
|
|
print(__doc__.strip())
|
2024-02-12 19:58:12 +00:00
|
|
|
print()
|
|
|
|
print()
|
2024-02-25 21:33:04 +00:00
|
|
|
if example_mod:
|
|
|
|
print(example_mod.example.strip())
|
|
|
|
print()
|
|
|
|
print()
|
2024-02-12 19:58:12 +00:00
|
|
|
print(mill_cli.__doc__.strip())
|
|
|
|
print()
|
|
|
|
print()
|
|
|
|
print(mill_cgi.__doc__.strip())
|
|
|
|
print()
|
|
|
|
print()
|
2024-02-25 21:33:04 +00:00
|
|
|
print(language_mod.__doc__.strip())
|
2024-02-12 19:58:12 +00:00
|
|
|
print()
|
|
|
|
print()
|
2024-02-25 21:33:04 +00:00
|
|
|
print(llm_engine_mod.__doc__.strip())
|
2024-02-12 19:58:12 +00:00
|
|
|
print()
|
|
|
|
print()
|
2024-02-25 21:33:04 +00:00
|
|
|
print(mill.__doc__.strip())
|
|
|
|
if example_mod:
|
|
|
|
print()
|
|
|
|
print()
|
|
|
|
print(example_mod.runnable_example.strip())
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
print_readme('markdown', 'llama.cpp')
|