Skip to content

Commit 458ce0d

Browse files
Colab links. Fixed notebook title generation from multi-line comment strings.
1 parent 0c4c657 commit 458ce0d

File tree

7 files changed

+78
-11
lines changed

7 files changed

+78
-11
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ for item in doc.aspects[0].extracted_items:
225225
# or `doc.get_aspect_by_name("Payment Terms").extracted_items`
226226

227227
```
228+
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/readme/quickstart_aspect.ipynb)
229+
228230

229231
### Concept extraction
230232

@@ -285,6 +287,7 @@ print(
285287
# or `doc.get_concept_by_name("Anomalies").extracted_items`
286288

287289
```
290+
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/readme/quickstart_concept.ipynb)
288291

289292
---
290293

dev/generate_notebooks.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,36 @@
3636

3737
def extract_first_comment(file_path: str | Path) -> Optional[str]:
3838
"""
39-
Extract the first comment line from a Python file to use as a title.
39+
Extract comment lines from the beginning of a Python file to use as a title.
40+
Captures multiple consecutive comment lines.
4041
4142
Args:
4243
file_path: Path to the Python file
4344
4445
Returns:
45-
The first comment if found, None otherwise
46+
The combined comment lines if found, None otherwise
4647
"""
48+
comment_lines = []
49+
4750
with open(file_path, "r", encoding="utf-8") as f:
4851
for line in f:
49-
# Skip empty lines
50-
if line.strip():
51-
# Check if the line starts with a comment
52-
match = re.match(r"^#\s*(.*)", line.strip())
53-
if match:
54-
return match.group(1)
55-
return None
52+
# Skip empty lines at the beginning
53+
if not line.strip():
54+
continue
55+
56+
# Check if the line starts with a comment
57+
match = re.match(r"^#\s*(.*)", line.strip())
58+
if match:
59+
comment_lines.append(match.group(1))
60+
else:
61+
# Stop at the first non-comment line
62+
break
63+
64+
if not comment_lines:
65+
return None
66+
67+
# Join all comment lines with a space
68+
return " ".join(comment_lines)
5669

5770

5871
def create_deterministic_metadata() -> dict[str, Any]:

dev/notebooks/docs/advanced/advanced_aspects_and_concepts_document.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"id": "cell_0",
66
"metadata": {},
77
"source": [
8-
"# Advanced Usage Example - Extracting aspects and concepts from a document, with references,"
8+
"# Advanced Usage Example - Extracting aspects and concepts from a document, with references, using concurrency"
99
]
1010
},
1111
{

dev/notebooks/docs/advanced/advanced_multiple_docs_pipeline.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"id": "cell_0",
66
"metadata": {},
77
"source": [
8-
"# Advanced Usage Example - analyzing multiple documents with a single pipeline,"
8+
"# Advanced Usage Example - analyzing multiple documents with a single pipeline, with different LLMs, concurrency and cost tracking"
99
]
1010
},
1111
{

dev/readme.template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Aspect is a defined area or topic within a document (or another aspect). Each as
6060
```python
6161
{{QUICKSTART_ASPECT}}
6262
```
63+
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/readme/quickstart_aspect.ipynb)
64+
6365

6466
### Concept extraction
6567

@@ -68,6 +70,7 @@ Concept is a unit of information or an entity, derived from an aspect or the bro
6870
```python
6971
{{QUICKSTART_CONCEPT}}
7072
```
73+
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/readme/quickstart_concept.ipynb)
7174

7275
---
7376

docs/source/advanced_usage.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Below are complete, self-contained examples demonstrating advanced usage of Cont
3434
.. literalinclude:: ../../dev/usage_examples/docs/advanced/advanced_aspects_with_concepts.py
3535
:language: python
3636

37+
.. raw:: html
38+
39+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/advanced/advanced_aspects_with_concepts.ipynb">
40+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
41+
</a>
42+
3743

3844
📊 Extracting Aspects and Concepts from a Document
3945
----------------------------------------------------
@@ -46,6 +52,12 @@ Below are complete, self-contained examples demonstrating advanced usage of Cont
4652
.. literalinclude:: ../../dev/usage_examples/docs/advanced/advanced_aspects_and_concepts_document.py
4753
:language: python
4854

55+
.. raw:: html
56+
57+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/advanced/advanced_aspects_and_concepts_document.ipynb">
58+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
59+
</a>
60+
4961

5062
🔄 Using a Multi-LLM Pipeline to Extract Data from Several Documents
5163
---------------------------------------------------------------------
@@ -57,3 +69,9 @@ Below are complete, self-contained examples demonstrating advanced usage of Cont
5769

5870
.. literalinclude:: ../../dev/usage_examples/docs/advanced/advanced_multiple_docs_pipeline.py
5971
:language: python
72+
73+
.. raw:: html
74+
75+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/advanced/advanced_multiple_docs_pipeline.ipynb">
76+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
77+
</a>

docs/source/quickstart.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ ContextGem follows a simple extraction process:
4949
.. literalinclude:: ../../dev/usage_examples/docs/quickstart/quickstart_aspect.py
5050
:language: python
5151

52+
.. raw:: html
53+
54+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/quickstart/quickstart_aspect.ipynb">
55+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
56+
</a>
57+
5258

5359
🌳 Extracting Aspect with Sub-Aspects
5460
--------------------------------------
@@ -63,6 +69,12 @@ ContextGem follows a simple extraction process:
6369
.. literalinclude:: ../../dev/usage_examples/docs/quickstart/quickstart_sub_aspect.py
6470
:language: python
6571

72+
.. raw:: html
73+
74+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/quickstart/quickstart_sub_aspect.ipynb">
75+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
76+
</a>
77+
6678

6779
🔍 Concept Extraction from Aspect
6880
----------------------------------
@@ -79,6 +91,12 @@ ContextGem follows a simple extraction process:
7991
.. literalinclude:: ../../dev/usage_examples/docs/quickstart/quickstart_concept_aspect.py
8092
:language: python
8193

94+
.. raw:: html
95+
96+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/quickstart/quickstart_concept_aspect.ipynb">
97+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
98+
</a>
99+
82100

83101
📝 Concept Extraction from Document (text)
84102
-------------------------------------------
@@ -95,6 +113,12 @@ ContextGem follows a simple extraction process:
95113
.. literalinclude:: ../../dev/usage_examples/docs/quickstart/quickstart_concept_document_text.py
96114
:language: python
97115

116+
.. raw:: html
117+
118+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/quickstart/quickstart_concept_document_text.ipynb">
119+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
120+
</a>
121+
98122

99123
🖼️ Concept Extraction from Document (vision)
100124
---------------------------------------------
@@ -108,3 +132,9 @@ ContextGem follows a simple extraction process:
108132

109133
.. literalinclude:: ../../dev/usage_examples/docs/quickstart/quickstart_concept_document_vision.py
110134
:language: python
135+
136+
.. raw:: html
137+
138+
<a target="_blank" href="https://colab.research.google.com/github/shcherbak-ai/contextgem/blob/dev/dev/notebooks/docs/quickstart/quickstart_concept_document_vision.ipynb">
139+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
140+
</a>

0 commit comments

Comments
 (0)