litdb 2.1.0__tar.gz → 2.1.2__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.
- {litdb-2.1.0 → litdb-2.1.2}/PKG-INFO +2 -1
- {litdb-2.1.0 → litdb-2.1.2}/README.org +1 -0
- {litdb-2.1.0 → litdb-2.1.2}/pyproject.toml +4 -3
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/app.py +16 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/chat.py +24 -4
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/cli.py +15 -3
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/utils.py +8 -3
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb.egg-info/PKG-INFO +2 -1
- {litdb-2.1.0 → litdb-2.1.2}/setup.cfg +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/__init__.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/audio.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/bibtex.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/coa.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/db.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/gpt.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/lab.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/openalex.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/pdf.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb/youtube.py +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb.egg-info/SOURCES.txt +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb.egg-info/dependency_links.txt +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb.egg-info/entry_points.txt +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb.egg-info/requires.txt +0 -0
- {litdb-2.1.0 → litdb-2.1.2}/src/litdb.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: litdb
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.2
|
|
4
4
|
Summary: A literature database tool with GPT integration.
|
|
5
5
|
Author-email: John Kitchin <jkitchin@andrew.cmu.edu>
|
|
6
6
|
Maintainer-email: John Kitchin <jkitchin@andrew.cmu.edu>
|
|
@@ -60,6 +60,7 @@ The idea is you add papers to your database, and then you can search it with nat
|
|
|
60
60
|
4. https://youtube.com/live/ZkKKuvVUWkE litdb and Emacs
|
|
61
61
|
5. https://youtube.com/live/j7rItPwWDaY litdb and Jupyter Lab
|
|
62
62
|
6. https://youtube.com/live/SUtvtc7l6y0 litdb + GPT enhancements
|
|
63
|
+
7. https://youtube.com/live/3FZ1ROnCC6Y litdb + LiteLLM and streamlit
|
|
63
64
|
|
|
64
65
|
** installation
|
|
65
66
|
|
|
@@ -17,6 +17,7 @@ The idea is you add papers to your database, and then you can search it with nat
|
|
|
17
17
|
4. https://youtube.com/live/ZkKKuvVUWkE litdb and Emacs
|
|
18
18
|
5. https://youtube.com/live/j7rItPwWDaY litdb and Jupyter Lab
|
|
19
19
|
6. https://youtube.com/live/SUtvtc7l6y0 litdb + GPT enhancements
|
|
20
|
+
7. https://youtube.com/live/3FZ1ROnCC6Y litdb + LiteLLM and streamlit
|
|
20
21
|
|
|
21
22
|
** installation
|
|
22
23
|
|
|
@@ -7,7 +7,7 @@ where = ["src"]
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "litdb"
|
|
10
|
-
version = "2.1.
|
|
10
|
+
version = "2.1.2"
|
|
11
11
|
authors = [
|
|
12
12
|
{name = "John Kitchin", email = "jkitchin@andrew.cmu.edu"},
|
|
13
13
|
]
|
|
@@ -44,9 +44,10 @@ dependencies = [
|
|
|
44
44
|
"pillow",
|
|
45
45
|
"bibtexparser",
|
|
46
46
|
|
|
47
|
+
# these are sort of hard to install, and rely on other libraries
|
|
48
|
+
# I document them here, but consider it optional
|
|
47
49
|
# "pyaudio",
|
|
48
50
|
# "playsound",
|
|
49
|
-
# "SpeechRecognition",
|
|
50
51
|
|
|
51
52
|
# for coa
|
|
52
53
|
"pandas",
|
|
@@ -60,7 +61,7 @@ dependencies = [
|
|
|
60
61
|
"webvtt-py",
|
|
61
62
|
|
|
62
63
|
# the streamlit app
|
|
63
|
-
"streamlit"
|
|
64
|
+
"streamlit"
|
|
64
65
|
]
|
|
65
66
|
|
|
66
67
|
[project.scripts]
|
|
@@ -6,16 +6,32 @@ example.
|
|
|
6
6
|
|
|
7
7
|
from litellm import completion
|
|
8
8
|
import streamlit as st
|
|
9
|
+
|
|
9
10
|
from litdb.utils import get_config
|
|
10
11
|
from litdb.db import get_db
|
|
11
12
|
from litdb.chat import get_rag_content
|
|
13
|
+
import os
|
|
12
14
|
|
|
13
15
|
config = get_config()
|
|
14
16
|
db = get_db()
|
|
15
17
|
|
|
16
18
|
gpt = config.get("llm", {"model": "ollama/llama2"})
|
|
17
19
|
|
|
20
|
+
|
|
21
|
+
dbf = os.path.join(config["root"], "litdb.libsql")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
kb = 1024
|
|
25
|
+
mb = 1024 * kb
|
|
26
|
+
gb = 1024 * mb
|
|
27
|
+
|
|
28
|
+
(nsources,) = db.execute("select count(source) from sources").fetchone()
|
|
29
|
+
|
|
18
30
|
st.title("LitGPT")
|
|
31
|
+
st.header("Database")
|
|
32
|
+
st.markdown(f"""Path: {dbf}
|
|
33
|
+
|
|
34
|
+
Database size: {os.path.getsize(dbf) / gb:1.2f} GB ({nsources} sources)""")
|
|
19
35
|
|
|
20
36
|
if "openai_model" not in st.session_state:
|
|
21
37
|
st.session_state["model"] = gpt["model"]
|
|
@@ -192,7 +192,7 @@ def get_completion(model, messages):
|
|
|
192
192
|
def chat(model=None, debug=False):
|
|
193
193
|
"""Start a LitGPT chat session using LiteLLM.
|
|
194
194
|
|
|
195
|
-
Use these
|
|
195
|
+
Use these strings to specify the model
|
|
196
196
|
(https://docs.litellm.ai/docs/providers).
|
|
197
197
|
|
|
198
198
|
ollama: ollama/llama3.3
|
|
@@ -227,9 +227,19 @@ def chat(model=None, debug=False):
|
|
|
227
227
|
!messages will output the current chat history to the shell.
|
|
228
228
|
!help to print a help message.
|
|
229
229
|
|
|
230
|
+
There is also some prompt expansion. [[file/url]] will be expanded to the
|
|
231
|
+
text in the file or url. We use docling for this, and otherwise assume they
|
|
232
|
+
are text to be read in.
|
|
233
|
+
|
|
234
|
+
You can have text in backticks, e.g. `np.linspace` which is expanded with
|
|
235
|
+
docstrings from Python where possible.
|
|
236
|
+
|
|
237
|
+
a line that starts with < is treated like a shell command. That command will
|
|
238
|
+
be run, and the output expanded into the prompt.
|
|
239
|
+
|
|
230
240
|
Use Ctrl-d to exit.
|
|
231
241
|
|
|
232
|
-
if debug
|
|
242
|
+
if debug is True, it will print some extra info.
|
|
233
243
|
|
|
234
244
|
"""
|
|
235
245
|
config = get_config()
|
|
@@ -249,10 +259,16 @@ def chat(model=None, debug=False):
|
|
|
249
259
|
# I assume you don't want to start there.
|
|
250
260
|
messages = []
|
|
251
261
|
|
|
252
|
-
rag = True # default to using this
|
|
253
|
-
|
|
254
262
|
while True:
|
|
263
|
+
rag = True # default to using this
|
|
264
|
+
|
|
255
265
|
prompt = input("LitGPT (Ctrl-d to quit, enter for mic)> ")
|
|
266
|
+
|
|
267
|
+
# line continuation
|
|
268
|
+
if prompt.endswith("\\"):
|
|
269
|
+
while next := input():
|
|
270
|
+
prompt += "\n" + next
|
|
271
|
+
|
|
256
272
|
if debug:
|
|
257
273
|
print(f"Starting with prompt: {prompt}")
|
|
258
274
|
|
|
@@ -315,11 +331,15 @@ The following subcommands can be used:
|
|
|
315
331
|
if "--norag" in prompt:
|
|
316
332
|
rag = False
|
|
317
333
|
prompt = prompt.replace("--norag", "")
|
|
334
|
+
if debug:
|
|
335
|
+
print("--norag found in prompt. Turned RAG off.")
|
|
318
336
|
|
|
319
337
|
match = re.search(r"--n=(\d+)", prompt)
|
|
320
338
|
if match:
|
|
321
339
|
n = int(match.group(1))
|
|
322
340
|
prompt = prompt.replace(match.group(0), "")
|
|
341
|
+
if debug:
|
|
342
|
+
print(f"Found {match.group(0)}, set n={n}")
|
|
323
343
|
else:
|
|
324
344
|
n = 3
|
|
325
345
|
|
|
@@ -687,7 +687,7 @@ def fulltext(query, n, fmt):
|
|
|
687
687
|
gpt = cli.command(gpt)
|
|
688
688
|
|
|
689
689
|
|
|
690
|
-
@click.command(help=
|
|
690
|
+
@click.command(help=chat.__doc__)
|
|
691
691
|
@click.option("--model", default=None, help="The LiteLLM model to use.")
|
|
692
692
|
@click.option("--debug", is_flag=True, default=False)
|
|
693
693
|
def chat_command(model, debug):
|
|
@@ -1203,10 +1203,13 @@ def bibtex(sources):
|
|
|
1203
1203
|
sources = sys.stdin.read().strip().split()
|
|
1204
1204
|
|
|
1205
1205
|
for source in sources:
|
|
1206
|
-
|
|
1206
|
+
work = db.execute(
|
|
1207
1207
|
"""select extra from sources where source = ?""", (source,)
|
|
1208
1208
|
).fetchone()
|
|
1209
|
-
|
|
1209
|
+
if work:
|
|
1210
|
+
richprint(dump_bibtex(json.loads(work[0])))
|
|
1211
|
+
else:
|
|
1212
|
+
print(f"No entry found for {source}")
|
|
1210
1213
|
|
|
1211
1214
|
|
|
1212
1215
|
@cli.command()
|
|
@@ -1483,5 +1486,14 @@ def app():
|
|
|
1483
1486
|
os.system(f"streamlit run {app}")
|
|
1484
1487
|
|
|
1485
1488
|
|
|
1489
|
+
@cli.command()
|
|
1490
|
+
def version():
|
|
1491
|
+
"""Print the version of litdb."""
|
|
1492
|
+
import pkg_resources
|
|
1493
|
+
|
|
1494
|
+
version = pkg_resources.get_distribution("litdb").version
|
|
1495
|
+
print(f"Litdb: version {version}")
|
|
1496
|
+
|
|
1497
|
+
|
|
1486
1498
|
if __name__ == "__main__":
|
|
1487
1499
|
cli()
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Utility functions used in litdb."""
|
|
2
|
+
|
|
1
3
|
import os
|
|
2
4
|
from pathlib import Path
|
|
3
5
|
import sys
|
|
@@ -7,7 +9,9 @@ import tomlkit
|
|
|
7
9
|
|
|
8
10
|
def find_root_directory(rootfile="litdb.toml"):
|
|
9
11
|
"""Search upwards for rootfile.
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
Returns the root directory, or the current directory if one is not found.
|
|
14
|
+
"""
|
|
11
15
|
wd = Path.cwd()
|
|
12
16
|
while wd != Path("/"):
|
|
13
17
|
if (wd / rootfile).exists():
|
|
@@ -19,7 +23,9 @@ def find_root_directory(rootfile="litdb.toml"):
|
|
|
19
23
|
|
|
20
24
|
def init_litdb():
|
|
21
25
|
"""Initialize litdb in the current directory.
|
|
22
|
-
|
|
26
|
+
|
|
27
|
+
This just creates the config.
|
|
28
|
+
"""
|
|
23
29
|
email = input("Email address: ")
|
|
24
30
|
api_key = input("OpenAlex API key (Enter if None): ")
|
|
25
31
|
|
|
@@ -48,7 +54,6 @@ def get_config():
|
|
|
48
54
|
1. There is a root / litdb.toml
|
|
49
55
|
2. There is a LITDB_ROOT/litdb.toml
|
|
50
56
|
"""
|
|
51
|
-
|
|
52
57
|
CONFIG = "litdb.toml"
|
|
53
58
|
root = find_root_directory()
|
|
54
59
|
if (root / CONFIG).exists():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: litdb
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.2
|
|
4
4
|
Summary: A literature database tool with GPT integration.
|
|
5
5
|
Author-email: John Kitchin <jkitchin@andrew.cmu.edu>
|
|
6
6
|
Maintainer-email: John Kitchin <jkitchin@andrew.cmu.edu>
|
|
@@ -60,6 +60,7 @@ The idea is you add papers to your database, and then you can search it with nat
|
|
|
60
60
|
4. https://youtube.com/live/ZkKKuvVUWkE litdb and Emacs
|
|
61
61
|
5. https://youtube.com/live/j7rItPwWDaY litdb and Jupyter Lab
|
|
62
62
|
6. https://youtube.com/live/SUtvtc7l6y0 litdb + GPT enhancements
|
|
63
|
+
7. https://youtube.com/live/3FZ1ROnCC6Y litdb + LiteLLM and streamlit
|
|
63
64
|
|
|
64
65
|
** installation
|
|
65
66
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|