gguf-core 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gguf_core-0.0.1/LICENSE +21 -0
- gguf_core-0.0.1/PKG-INFO +72 -0
- gguf_core-0.0.1/README.md +61 -0
- gguf_core-0.0.1/pyproject.toml +20 -0
- gguf_core-0.0.1/src/gguf_core/__init__.py +152 -0
- gguf_core-0.0.1/src/gguf_core/logo.png +0 -0
gguf_core-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 calcuis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
gguf_core-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gguf-core
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: a simple way to interact with llama with gguf file(s)
|
|
5
|
+
Author-email: calcuis <calculatics@gmail.com>
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Requires-Dist: llama-core
|
|
9
|
+
Project-URL: Homepage, https://github.com/calcuis/gguf-connector
|
|
10
|
+
Project-URL: Issues, https://github.com/calcuis/gguf-connector/issues
|
|
11
|
+
|
|
12
|
+
### GGUF core
|
|
13
|
+
|
|
14
|
+
[<img src="https://raw.githubusercontent.com/calcuis/gguf-connector/master/gguf.gif" width="128" height="128">](https://github.com/calcuis/gguf-connector)
|
|
15
|
+
|
|
16
|
+
This package is a GGUF (GPT-Generated Unified Format) file caller.
|
|
17
|
+
#### install the caller via pip/pip3 (once only):
|
|
18
|
+
```
|
|
19
|
+
pip install gguf-core
|
|
20
|
+
```
|
|
21
|
+
#### update the caller (if not in the latest version) by:
|
|
22
|
+
```
|
|
23
|
+
pip install gguf-core --upgrade
|
|
24
|
+
```
|
|
25
|
+
### user manual
|
|
26
|
+
This is a cmd-based (command line) package, you can find the user manual by adding the flag -h or --help.
|
|
27
|
+
```
|
|
28
|
+
gguf -h
|
|
29
|
+
```
|
|
30
|
+
#### check current version
|
|
31
|
+
```
|
|
32
|
+
gguf -v
|
|
33
|
+
```
|
|
34
|
+
#### gui connector
|
|
35
|
+
```
|
|
36
|
+
gguf g
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
GGUF file(s) in the same directory will automatically be detected by the caller, hence, a selection menu will be shown in the console as below.
|
|
40
|
+
|
|
41
|
+
[<img src="https://raw.githubusercontent.com/calcuis/chatgpt-model-selector/master/demo.gif" width="350" height="280">](https://github.com/calcuis/chatgpt-model-selector/blob/main/demo.gif)
|
|
42
|
+
[<img src="https://raw.githubusercontent.com/calcuis/chatgpt-model-selector/master/demo1.gif" width="350" height="280">](https://github.com/calcuis/chatgpt-model-selector/blob/main/demo1.gif)
|
|
43
|
+
|
|
44
|
+
### clone feature
|
|
45
|
+
```
|
|
46
|
+
gguf clone [url]
|
|
47
|
+
```
|
|
48
|
+
With this fast clone feature, you can clone any (GGUF model) file from URL, save it automatically in the current directory, and get it ready to connect locally (run it with your own machine offline); depends on the file size, as well as the network connectivity, it may take a while to complete the clone process; and you can see a dynamic progress bar showing the downloading status in this latest version. (an universal issue was detected for mac users: ssl cert. verify failed; possible solution: click Install Certificates.command under your Python version folder)
|
|
49
|
+
|
|
50
|
+
#### sample model(s) available to download (try out)
|
|
51
|
+
For general purpose
|
|
52
|
+
[chat.gguf] (size: around 2GB or less)
|
|
53
|
+
```
|
|
54
|
+
gguf clone https://huggingface.co/calcuis/chat/resolve/main/chat.gguf
|
|
55
|
+
```
|
|
56
|
+
For coding
|
|
57
|
+
[code.gguf] (size: around 3GB or more)
|
|
58
|
+
```
|
|
59
|
+
gguf clone https://huggingface.co/calcuis/chat/resolve/main/code.gguf
|
|
60
|
+
```
|
|
61
|
+
For health/medical advice
|
|
62
|
+
[medi.gguf] (size: around 3GB or more)
|
|
63
|
+
```
|
|
64
|
+
gguf clone https://huggingface.co/calcuis/chat/resolve/main/medi.gguf
|
|
65
|
+
```
|
|
66
|
+
***those are all experimental models; no guarantee on quality
|
|
67
|
+
|
|
68
|
+
#### sample model list
|
|
69
|
+
You can either use the clone feature above or opt a sample GGUF straight from the lazy list by:
|
|
70
|
+
```
|
|
71
|
+
gguf s
|
|
72
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
### GGUF core
|
|
2
|
+
|
|
3
|
+
[<img src="https://raw.githubusercontent.com/calcuis/gguf-connector/master/gguf.gif" width="128" height="128">](https://github.com/calcuis/gguf-connector)
|
|
4
|
+
|
|
5
|
+
This package is a GGUF (GPT-Generated Unified Format) file caller.
|
|
6
|
+
#### install the caller via pip/pip3 (once only):
|
|
7
|
+
```
|
|
8
|
+
pip install gguf-core
|
|
9
|
+
```
|
|
10
|
+
#### update the caller (if not in the latest version) by:
|
|
11
|
+
```
|
|
12
|
+
pip install gguf-core --upgrade
|
|
13
|
+
```
|
|
14
|
+
### user manual
|
|
15
|
+
This is a cmd-based (command line) package, you can find the user manual by adding the flag -h or --help.
|
|
16
|
+
```
|
|
17
|
+
gguf -h
|
|
18
|
+
```
|
|
19
|
+
#### check current version
|
|
20
|
+
```
|
|
21
|
+
gguf -v
|
|
22
|
+
```
|
|
23
|
+
#### gui connector
|
|
24
|
+
```
|
|
25
|
+
gguf g
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
GGUF file(s) in the same directory will automatically be detected by the caller, hence, a selection menu will be shown in the console as below.
|
|
29
|
+
|
|
30
|
+
[<img src="https://raw.githubusercontent.com/calcuis/chatgpt-model-selector/master/demo.gif" width="350" height="280">](https://github.com/calcuis/chatgpt-model-selector/blob/main/demo.gif)
|
|
31
|
+
[<img src="https://raw.githubusercontent.com/calcuis/chatgpt-model-selector/master/demo1.gif" width="350" height="280">](https://github.com/calcuis/chatgpt-model-selector/blob/main/demo1.gif)
|
|
32
|
+
|
|
33
|
+
### clone feature
|
|
34
|
+
```
|
|
35
|
+
gguf clone [url]
|
|
36
|
+
```
|
|
37
|
+
With this fast clone feature, you can clone any (GGUF model) file from URL, save it automatically in the current directory, and get it ready to connect locally (run it with your own machine offline); depends on the file size, as well as the network connectivity, it may take a while to complete the clone process; and you can see a dynamic progress bar showing the downloading status in this latest version. (an universal issue was detected for mac users: ssl cert. verify failed; possible solution: click Install Certificates.command under your Python version folder)
|
|
38
|
+
|
|
39
|
+
#### sample model(s) available to download (try out)
|
|
40
|
+
For general purpose
|
|
41
|
+
[chat.gguf] (size: around 2GB or less)
|
|
42
|
+
```
|
|
43
|
+
gguf clone https://huggingface.co/calcuis/chat/resolve/main/chat.gguf
|
|
44
|
+
```
|
|
45
|
+
For coding
|
|
46
|
+
[code.gguf] (size: around 3GB or more)
|
|
47
|
+
```
|
|
48
|
+
gguf clone https://huggingface.co/calcuis/chat/resolve/main/code.gguf
|
|
49
|
+
```
|
|
50
|
+
For health/medical advice
|
|
51
|
+
[medi.gguf] (size: around 3GB or more)
|
|
52
|
+
```
|
|
53
|
+
gguf clone https://huggingface.co/calcuis/chat/resolve/main/medi.gguf
|
|
54
|
+
```
|
|
55
|
+
***those are all experimental models; no guarantee on quality
|
|
56
|
+
|
|
57
|
+
#### sample model list
|
|
58
|
+
You can either use the clone feature above or opt a sample GGUF straight from the lazy list by:
|
|
59
|
+
```
|
|
60
|
+
gguf s
|
|
61
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_core"]
|
|
3
|
+
build-backend = "flit_core.buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "gguf-core"
|
|
7
|
+
authors = [{name = "calcuis", email = "calculatics@gmail.com"}]
|
|
8
|
+
description = "a simple way to interact with llama with gguf file(s)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {file = "LICENSE"}
|
|
11
|
+
classifiers = ["License :: OSI Approved :: MIT License"]
|
|
12
|
+
dynamic = ["version"]
|
|
13
|
+
dependencies = ["llama-core"]
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://github.com/calcuis/gguf-connector"
|
|
17
|
+
Issues = "https://github.com/calcuis/gguf-connector/issues"
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
gguf = "gguf_core.__init__:__init__"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# !/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
__version__="0.0.1"
|
|
4
|
+
|
|
5
|
+
import argparse, json, os.path, urllib.request
|
|
6
|
+
from tqdm import tqdm
|
|
7
|
+
from tkinter import *
|
|
8
|
+
|
|
9
|
+
def get_file_size(url):
|
|
10
|
+
with urllib.request.urlopen(url) as response:
|
|
11
|
+
size = int(response.headers['Content-Length'])
|
|
12
|
+
return size
|
|
13
|
+
|
|
14
|
+
def clone_file(url):
|
|
15
|
+
try:
|
|
16
|
+
file_size = get_file_size(url)
|
|
17
|
+
filename = os.path.basename(url)
|
|
18
|
+
# Download the file with progress
|
|
19
|
+
with urllib.request.urlopen(url) as response, \
|
|
20
|
+
open(filename, 'wb') as file, \
|
|
21
|
+
tqdm(total=file_size, unit='B', unit_scale=True, unit_divisor=1024, desc=f'Downloading {filename}') as pbar:
|
|
22
|
+
# Download in chunks and update the progress bar
|
|
23
|
+
chunk_size = 1024 # 1 KB
|
|
24
|
+
while True:
|
|
25
|
+
chunk = response.read(chunk_size)
|
|
26
|
+
if not chunk:
|
|
27
|
+
break
|
|
28
|
+
file.write(chunk)
|
|
29
|
+
pbar.update(len(chunk))
|
|
30
|
+
print(f"File cloned successfully and saved as '{filename}' in the current directory.")
|
|
31
|
+
except Exception as e:
|
|
32
|
+
print(f"Error: {e}")
|
|
33
|
+
|
|
34
|
+
def read_json_file(file_path):
|
|
35
|
+
response = urllib.request.urlopen(file_path)
|
|
36
|
+
data = json.loads(response.read())
|
|
37
|
+
# with open(file_path, 'r') as file:
|
|
38
|
+
# data = json.load(file)
|
|
39
|
+
return data
|
|
40
|
+
|
|
41
|
+
def extract_names(data):
|
|
42
|
+
for idx, entry in enumerate(data, start=1):
|
|
43
|
+
print(f'{idx}. {entry["name"]}')
|
|
44
|
+
|
|
45
|
+
def handle_user_input(data):
|
|
46
|
+
while True:
|
|
47
|
+
user_choice = input(f"Enter your choice (1 to {len(data)}) or 'q' to quit: ")
|
|
48
|
+
if user_choice.lower() == 'q':
|
|
49
|
+
break
|
|
50
|
+
try:
|
|
51
|
+
index = int(user_choice)
|
|
52
|
+
if 1 <= index <= len(data):
|
|
53
|
+
source_url = data[index - 1]["url"]
|
|
54
|
+
clone_file(source_url)
|
|
55
|
+
break
|
|
56
|
+
else:
|
|
57
|
+
print("Invalid selection. Please enter a valid number.")
|
|
58
|
+
except ValueError:
|
|
59
|
+
print("Invalid input. Please enter a number.")
|
|
60
|
+
|
|
61
|
+
def __init__():
|
|
62
|
+
parser = argparse.ArgumentParser(description="cgg will execute different functions based on command-line arguments")
|
|
63
|
+
parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__)
|
|
64
|
+
|
|
65
|
+
subparsers = parser.add_subparsers(title="subcommands", dest="subcommand", help="choose a subcommand:")
|
|
66
|
+
# Subparser for 'clone [URL]' subcommand
|
|
67
|
+
clone_parser = subparsers.add_parser('clone', help='download a GGUF file/model from URL')
|
|
68
|
+
clone_parser.add_argument('url', type=str, help='URL to download from (i.e., egg clone [url])')
|
|
69
|
+
# Subparser for 'menu/cpp/c/gpp/g/s' subcommand
|
|
70
|
+
# subparsers.add_parser('menu', help='connector selection list:')
|
|
71
|
+
# subparsers.add_parser('cpp', help='cpp connector')
|
|
72
|
+
# subparsers.add_parser('gpp', help='gpp connector')
|
|
73
|
+
# subparsers.add_parser('c', help='c connector')
|
|
74
|
+
subparsers.add_parser('g', help='GUI connector')
|
|
75
|
+
subparsers.add_parser('s', help='sample GGUF list (ready)')
|
|
76
|
+
args = parser.parse_args()
|
|
77
|
+
|
|
78
|
+
if args.subcommand == 'clone':
|
|
79
|
+
clone_file(args.url)
|
|
80
|
+
elif args.subcommand == 's':
|
|
81
|
+
file_path = "https://raw.githubusercontent.com/calcuis/gguf-connector/main/src/gguf_connector/data.json"
|
|
82
|
+
# file_path = os.path.join(os.path.dirname(__file__), 'data.json')
|
|
83
|
+
json_data = read_json_file(file_path)
|
|
84
|
+
print("Please select a GGUF file to download:")
|
|
85
|
+
extract_names(json_data)
|
|
86
|
+
handle_user_input(json_data)
|
|
87
|
+
# elif args.subcommand == 'menu':
|
|
88
|
+
# from gguf_connector import menu
|
|
89
|
+
# elif args.subcommand == 'cpp':
|
|
90
|
+
# from gguf_connector import cpp
|
|
91
|
+
# elif args.subcommand == 'c':
|
|
92
|
+
# from gguf_connector import c
|
|
93
|
+
# elif args.subcommand == 'gpp':
|
|
94
|
+
# from gguf_connector import gpp
|
|
95
|
+
elif args.subcommand == 'g':
|
|
96
|
+
import os
|
|
97
|
+
|
|
98
|
+
gguf_files = [file for file in os.listdir() if file.endswith('.gguf')]
|
|
99
|
+
|
|
100
|
+
if gguf_files:
|
|
101
|
+
print("GGUF file(s) available. Select which one to use:")
|
|
102
|
+
|
|
103
|
+
for index, file_name in enumerate(gguf_files, start=1):
|
|
104
|
+
print(f"{index}. {file_name}")
|
|
105
|
+
|
|
106
|
+
choice = input(f"Enter your choice (1 to {len(gguf_files)}): ")
|
|
107
|
+
|
|
108
|
+
try:
|
|
109
|
+
choice_index=int(choice)-1
|
|
110
|
+
selected_file=gguf_files[choice_index]
|
|
111
|
+
print(f"Model file: {selected_file} is selected!")
|
|
112
|
+
ModelPath=selected_file
|
|
113
|
+
|
|
114
|
+
from llama_core import Llama
|
|
115
|
+
llm = Llama(model_path=ModelPath)
|
|
116
|
+
|
|
117
|
+
import tkinter.scrolledtext as st
|
|
118
|
+
|
|
119
|
+
root = Tk()
|
|
120
|
+
root.title("GGuF")
|
|
121
|
+
root.columnconfigure([0, 1, 2], minsize=150)
|
|
122
|
+
root.rowconfigure(0, weight=2)
|
|
123
|
+
root.rowconfigure(1, weight=1)
|
|
124
|
+
|
|
125
|
+
icon = PhotoImage(file = os.path.join(os.path.dirname(__file__), "logo.png"))
|
|
126
|
+
root.iconphoto(False, icon)
|
|
127
|
+
|
|
128
|
+
i = Entry()
|
|
129
|
+
o = st.ScrolledText()
|
|
130
|
+
|
|
131
|
+
def submit(i):
|
|
132
|
+
root.title("Processing...")
|
|
133
|
+
|
|
134
|
+
output = llm("Q: "+str(i.get()), max_tokens=2048, echo=True)
|
|
135
|
+
answer = output['choices'][0]['text']
|
|
136
|
+
print(answer)
|
|
137
|
+
o.insert(INSERT, answer+"\n\n")
|
|
138
|
+
|
|
139
|
+
i.delete(0, END)
|
|
140
|
+
root.title("GGuF")
|
|
141
|
+
|
|
142
|
+
btn = Button(text = "Submit", command = lambda: submit(i))
|
|
143
|
+
i.grid(row=1, columnspan=2, sticky="nsew")
|
|
144
|
+
btn.grid(row=1, column=2, sticky="nsew")
|
|
145
|
+
o.grid(row=0, columnspan=3, sticky="nsew")
|
|
146
|
+
root.mainloop()
|
|
147
|
+
|
|
148
|
+
except (ValueError, IndexError):
|
|
149
|
+
print("Invalid choice. Please enter a valid number.")
|
|
150
|
+
else:
|
|
151
|
+
print("No GGUF files are available in the current directory.")
|
|
152
|
+
input("--- Press ENTER To Exit ---")
|
|
Binary file
|