Skip to content

Commit e4b491b

Browse files
committed
Merge branch 'main' of github.com:AnswerDotAI/contextpack
2 parents 1cf1570 + eefd0e9 commit e4b491b

File tree

3 files changed

+44
-33
lines changed

3 files changed

+44
-33
lines changed

contextpack/_modidx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@
2626
'contextpack.core.Topic': ('core.html#topic', 'contextpack/core.py'),
2727
'contextpack.core.Topic.__iter__': ('core.html#topic.__iter__', 'contextpack/core.py'),
2828
'contextpack.core.Topic.__repr__': ('core.html#topic.__repr__', 'contextpack/core.py'),
29-
'contextpack.core.Topic._children': ('core.html#topic._children', 'contextpack/core.py')}}}
29+
'contextpack.core.Topic._children': ('core.html#topic._children', 'contextpack/core.py'),
30+
'contextpack.core.xget': ('core.html#xget', 'contextpack/core.py')}}}

contextpack/core.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
# %% auto 0
66
__all__ = ['ctx_docker', 'ctx_fastcore', 'ctx_nbclassic_server', 'ctx_fasthtml', 'ctx_claudette', 'ctx_fastlite_sqlutils',
7-
'Topic', 'ST', 'CTX_Fastlite_Sqlutils', 'CTX_Claudette', 'CTX_Docker', 'CTX_FastHtml', 'CTX_NBClassicServer',
8-
'CTX_Fastcore']
7+
'Topic', 'ST', 'xget', 'CTX_Fastlite_Sqlutils', 'CTX_Claudette', 'CTX_Docker', 'CTX_FastHtml',
8+
'CTX_NBClassicServer', 'CTX_Fastcore']
99

1010
# %% ../nbs/00_core.ipynb 3
11-
from typing import Callable
1211
from contextkit import *
1312
from fastcore.utils import *
13+
from typing import Callable
14+
15+
import httpx
1416

1517
# %% ../nbs/00_core.ipynb 5
1618
class Topic:
@@ -40,25 +42,28 @@ def __repr__(self):
4042

4143

4244
# %% ../nbs/00_core.ipynb 8
45+
def xget(url): return httpx.get(url).text
46+
47+
# %% ../nbs/00_core.ipynb 9
4348
class CTX_Fastlite_Sqlutils(Topic):
4449
"LLM contexts on fastlite-sqlutils"
4550
def __init__(self):
46-
self.fastlite_index = ST('https://answerdotai.github.io/fastlite/index.html.md')
47-
self.fastlite_core = ST('https://answerdotai.github.io/fastlite/core.html.md')
51+
self.fastlite_index = ST('https://answerdotai.github.io/fastlite/index.html.md', xget)
52+
self.fastlite_core = ST('https://answerdotai.github.io/fastlite/core.html.md', xget)
4853
self.sqlite_utils_docs = ST('https://sqlite-utils.datasette.io/en/stable/python-api.html',
4954
lambda url:read_url(url,sel='#sqlite-utils-python-library'))
5055

5156

52-
# %% ../nbs/00_core.ipynb 16
57+
# %% ../nbs/00_core.ipynb 17
5358
class CTX_Claudette(Topic):
5459
def __init__(self):
55-
self.async_docs = ST('https://claudette.answer.ai/async.html.md')
56-
self.core_docs = ST('https://claudette.answer.ai/core.html.md')
57-
self.toolloop_docs = ST('https://claudette.answer.ai/toolloop.html.md')
60+
self.async_docs = ST('https://claudette.answer.ai/async.html.md', xget)
61+
self.core_docs = ST('https://claudette.answer.ai/core.html.md', xget)
62+
self.toolloop_docs = ST('https://claudette.answer.ai/toolloop.html.md', xget)
5863

5964

6065

61-
# %% ../nbs/00_core.ipynb 17
66+
# %% ../nbs/00_core.ipynb 18
6267
class CTX_Docker(Topic):
6368
def __init__(self):
6469
self.compose_file = ST('https://docs.docker.com/reference/compose-file/')
@@ -74,27 +79,27 @@ def __init__(self):
7479
for name,url in pageurls: setattr(self,name,ST(url))
7580

7681

77-
# %% ../nbs/00_core.ipynb 18
82+
# %% ../nbs/00_core.ipynb 19
7883
class CTX_FastHtml(Topic):
7984
"LLM-friendly documentation for FastHtml"
8085
def __init__(self):
81-
self.fasthtml_llms_ctx = ST('https://docs.fastht.ml/llms-ctx.txt')
86+
self.fasthtml_llms_ctx = ST('https://docs.fastht.ml/llms-ctx.txt', xget)
8287
self.hypermedia_summary = ST('https://gist.github.com/jph00/4ad7d35ad79013aded41b5ba535a12a3',read_gist)
8388

8489

85-
# %% ../nbs/00_core.ipynb 19
90+
# %% ../nbs/00_core.ipynb 20
8691
class CTX_NBClassicServer(Topic):
8792
def __init__(self):
8893
self.nbclassic_server = ST('https://nbclassic.readthedocs.io/en/latest/nbclassic.html',
8994
lambda url:read_url(url,self='bd-article'))
9095

9196

92-
# %% ../nbs/00_core.ipynb 20
97+
# %% ../nbs/00_core.ipynb 21
9398
class CTX_Fastcore(Topic):
9499
def __init__(self):
95-
self.fc_llms_ctx = ST('https://fastcore.fast.ai/llms-ctx.txt')
100+
self.fc_llms_ctx = ST('https://fastcore.fast.ai/llms-ctx.txt', xget)
96101

97-
# %% ../nbs/00_core.ipynb 22
102+
# %% ../nbs/00_core.ipynb 23
98103
ctx_docker = CTX_Docker()
99104
ctx_fastcore = CTX_Fastcore()
100105
ctx_nbclassic_server = CTX_NBClassicServer()

nbs/00_core.ipynb

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@
3535
"outputs": [],
3636
"source": [
3737
"#| export\n",
38-
"\n",
39-
"from typing import Callable\n",
4038
"from contextkit import *\n",
41-
"from fastcore.utils import *"
39+
"from fastcore.utils import *\n",
40+
"from typing import Callable\n",
41+
"\n",
42+
"import httpx"
4243
]
4344
},
4445
{
@@ -96,6 +97,16 @@
9697
"We define a topic via a `Topic` subclass, which defines attributes which are `ST`s: "
9798
]
9899
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": null,
103+
"metadata": {},
104+
"outputs": [],
105+
"source": [
106+
"#| export\n",
107+
"def xget(url): return httpx.get(url).text"
108+
]
109+
},
99110
{
100111
"cell_type": "code",
101112
"execution_count": null,
@@ -107,8 +118,8 @@
107118
"class CTX_Fastlite_Sqlutils(Topic):\n",
108119
" \"LLM contexts on fastlite-sqlutils\"\n",
109120
" def __init__(self):\n",
110-
" self.fastlite_index = ST('https://answerdotai.github.io/fastlite/index.html.md')\n",
111-
" self.fastlite_core = ST('https://answerdotai.github.io/fastlite/core.html.md')\n",
121+
" self.fastlite_index = ST('https://answerdotai.github.io/fastlite/index.html.md', xget)\n",
122+
" self.fastlite_core = ST('https://answerdotai.github.io/fastlite/core.html.md', xget)\n",
112123
" self.sqlite_utils_docs = ST('https://sqlite-utils.datasette.io/en/stable/python-api.html',\n",
113124
" lambda url:read_url(url,sel='#sqlite-utils-python-library'))\n"
114125
]
@@ -243,12 +254,11 @@
243254
"outputs": [],
244255
"source": [
245256
"#| export\n",
246-
"\n",
247257
"class CTX_Claudette(Topic):\n",
248258
" def __init__(self):\n",
249-
" self.async_docs = ST('https://claudette.answer.ai/async.html.md')\n",
250-
" self.core_docs = ST('https://claudette.answer.ai/core.html.md')\n",
251-
" self.toolloop_docs = ST('https://claudette.answer.ai/toolloop.html.md')\n",
259+
" self.async_docs = ST('https://claudette.answer.ai/async.html.md', xget)\n",
260+
" self.core_docs = ST('https://claudette.answer.ai/core.html.md', xget)\n",
261+
" self.toolloop_docs = ST('https://claudette.answer.ai/toolloop.html.md', xget)\n",
252262
"\n"
253263
]
254264
},
@@ -259,7 +269,6 @@
259269
"outputs": [],
260270
"source": [
261271
"#| export\n",
262-
"\n",
263272
"class CTX_Docker(Topic):\n",
264273
" def __init__(self):\n",
265274
" self.compose_file = ST('https://docs.docker.com/reference/compose-file/')\n",
@@ -283,11 +292,10 @@
283292
"outputs": [],
284293
"source": [
285294
"#| export\n",
286-
"\n",
287295
"class CTX_FastHtml(Topic):\n",
288296
" \"LLM-friendly documentation for FastHtml\"\n",
289297
" def __init__(self):\n",
290-
" self.fasthtml_llms_ctx = ST('https://docs.fastht.ml/llms-ctx.txt')\n",
298+
" self.fasthtml_llms_ctx = ST('https://docs.fastht.ml/llms-ctx.txt', xget)\n",
291299
" self.hypermedia_summary = ST('https://gist.github.com/jph00/4ad7d35ad79013aded41b5ba535a12a3',read_gist)\n"
292300
]
293301
},
@@ -298,7 +306,6 @@
298306
"outputs": [],
299307
"source": [
300308
"#| export\n",
301-
"\n",
302309
"class CTX_NBClassicServer(Topic):\n",
303310
" def __init__(self):\n",
304311
" self.nbclassic_server = ST('https://nbclassic.readthedocs.io/en/latest/nbclassic.html',\n",
@@ -312,10 +319,9 @@
312319
"outputs": [],
313320
"source": [
314321
"#| export\n",
315-
"\n",
316322
"class CTX_Fastcore(Topic):\n",
317323
" def __init__(self):\n",
318-
" self.fc_llms_ctx = ST('https://fastcore.fast.ai/llms-ctx.txt')"
324+
" self.fc_llms_ctx = ST('https://fastcore.fast.ai/llms-ctx.txt', xget)"
319325
]
320326
},
321327
{
@@ -332,7 +338,6 @@
332338
"outputs": [],
333339
"source": [
334340
"#| export\n",
335-
"\n",
336341
"ctx_docker = CTX_Docker()\n",
337342
"ctx_fastcore = CTX_Fastcore()\n",
338343
"ctx_nbclassic_server = CTX_NBClassicServer()\n",

0 commit comments

Comments
 (0)