Skip to content

Commit c05ffd6

Browse files
committed
Update usage examples to use model
1 parent 2a6ce43 commit c05ffd6

File tree

6 files changed

+302
-7
lines changed

6 files changed

+302
-7
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ config = lx.factory.ModelConfig(
3939
),
4040
)
4141

42+
model = lx.factory.create_model(config)
43+
4244
result = lx.extract(
43-
config=config,
45+
model=model,
4446
text_or_documents="Your input text",
4547
prompt_description="Extract entities",
4648
examples=[...],
@@ -83,8 +85,10 @@ config = lx.factory.ModelConfig(
8385
),
8486
)
8587

88+
model = lx.factory.create_model(config)
89+
8690
result = lx.extract(
87-
config=config,
91+
model=model,
8892
...
8993
)
9094
```

examples/usage_example.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@
114114
" ),\n",
115115
")\n",
116116
"\n",
117+
"model = lx.factory.create_model(config)\n",
117118
"\n",
118119
"result = lx.extract(\n",
120+
" model=model,\n",
119121
" text_or_documents=input_text,\n",
120122
" prompt_description=prompt,\n",
121123
" examples=examples,\n",
122-
" config=config,\n",
123124
" fence_output=False,\n",
124125
" use_schema_constraints=False,\n",
125126
" debug=False,\n",

examples/usage_example_file.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@
115115
" ),\n",
116116
")\n",
117117
"\n",
118+
"model = lx.factory.create_model(config)\n",
118119
"\n",
119120
"result = lx.extract(\n",
121+
" model=model,\n",
120122
" text_or_documents=input_text,\n",
121123
" prompt_description=prompt,\n",
122124
" examples=examples,\n",
123-
" config=config,\n",
124125
" fence_output=False,\n",
125126
" use_schema_constraints=False,\n",
126127
" debug=False,\n",

examples/usage_example_server.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@
7272
" ),\n",
7373
")\n",
7474
"\n",
75+
"model = lx.factory.create_model(config)\n",
76+
"\n",
7577
"\n",
7678
"result = lx.extract(\n",
79+
" model=model,\n",
7780
" text_or_documents=input_text,\n",
7881
" prompt_description=prompt,\n",
7982
" examples=examples,\n",
80-
" config=config,\n",
8183
" fence_output=False,\n",
8284
" use_schema_constraints=False,\n",
8385
" debug=False,\n",
@@ -199,7 +201,7 @@
199201
" <div id=\"attributesContainer\"></div>\n",
200202
" </div>\n",
201203
" <div class=\"lx-text-window\" id=\"textWindow\">\n",
202-
" <span class=\"lx-highlight lx-current-highlight\" data-idx=\"0\" style=\"background-color:#D2E3FC;\">Lady Juliet</span> <span class=\"lx-highlight\" data-idx=\"1\" style=\"background-color:#C8E6C9;\">gazed longingly</span> at the stars, <span class=\"lx-highlight\" data-idx=\"2\" style=\"background-color:#D2E3FC;\">her heart</span> aching <span class=\"lx-highlight\" data-idx=\"3\" style=\"background-color:#FEF0C3;\">for Romeo</span>\n",
204+
" <span class=\"lx-highlight lx-current-highlight\" data-idx=\"0\" style=\"background-color:#D2E3FC;\">Lady Juliet</span> <span class=\"lx-highlight\" data-idx=\"1\" style=\"background-color:#C8E6C9;\">gazed longingly</span> at the stars, <span class=\"lx-highlight\" data-idx=\"2\" style=\"background-color:#FEF0C3;\">her heart aching for <span class=\"lx-highlight\" data-idx=\"3\" style=\"background-color:#D2E3FC;\">Romeo</span></span>\n",
203205
" </div>\n",
204206
" <div class=\"lx-controls\">\n",
205207
" <div class=\"lx-button-row\">\n",
@@ -221,7 +223,7 @@
221223
"\n",
222224
"<script>\n",
223225
" (function() {\n",
224-
" const extractions = [{\"index\": 0, \"class\": \"character\", \"text\": \"Lady Juliet\", \"color\": \"#D2E3FC\", \"startPos\": 0, \"endPos\": 11, \"beforeText\": \"\", \"extractionText\": \"Lady Juliet\", \"afterText\": \" gazed longingly at the stars, her heart aching for Romeo\", \"attributesHtml\": \"<div><strong>class:</strong> character</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">emotional_state</span>: <span class=\\\"lx-attr-value\\\">longing</span>}</div>\"}, {\"index\": 1, \"class\": \"emotion\", \"text\": \"gazed longingly\", \"color\": \"#C8E6C9\", \"startPos\": 12, \"endPos\": 27, \"beforeText\": \"Lady Juliet \", \"extractionText\": \"gazed longingly\", \"afterText\": \" at the stars, her heart aching for Romeo\", \"attributesHtml\": \"<div><strong>class:</strong> emotion</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">feeling</span>: <span class=\\\"lx-attr-value\\\">intense desire</span>}</div>\"}, {\"index\": 2, \"class\": \"character\", \"text\": \"her heart\", \"color\": \"#D2E3FC\", \"startPos\": 42, \"endPos\": 51, \"beforeText\": \"Lady Juliet gazed longingly at the stars, \", \"extractionText\": \"her heart\", \"afterText\": \" aching for Romeo\", \"attributesHtml\": \"<div><strong>class:</strong> character</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">emotional_state</span>: <span class=\\\"lx-attr-value\\\">aching</span>}</div>\"}, {\"index\": 3, \"class\": \"relationship\", \"text\": \"for Romeo\", \"color\": \"#FEF0C3\", \"startPos\": 59, \"endPos\": 68, \"beforeText\": \"Lady Juliet gazed longingly at the stars, her heart aching \", \"extractionText\": \"for Romeo\", \"afterText\": \"\", \"attributesHtml\": \"<div><strong>class:</strong> relationship</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">type</span>: <span class=\\\"lx-attr-value\\\">affectionate longing</span>}</div>\"}];\n",
226+
" const extractions = [{\"index\": 0, \"class\": \"character\", \"text\": \"Lady Juliet\", \"color\": \"#D2E3FC\", \"startPos\": 0, \"endPos\": 11, \"beforeText\": \"\", \"extractionText\": \"Lady Juliet\", \"afterText\": \" gazed longingly at the stars, her heart aching for Romeo\", \"attributesHtml\": \"<div><strong>class:</strong> character</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">emotional_state</span>: <span class=\\\"lx-attr-value\\\">longing</span>}</div>\"}, {\"index\": 1, \"class\": \"emotion\", \"text\": \"gazed longingly\", \"color\": \"#C8E6C9\", \"startPos\": 12, \"endPos\": 27, \"beforeText\": \"Lady Juliet \", \"extractionText\": \"gazed longingly\", \"afterText\": \" at the stars, her heart aching for Romeo\", \"attributesHtml\": \"<div><strong>class:</strong> emotion</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">feeling</span>: <span class=\\\"lx-attr-value\\\">intense desire</span>}</div>\"}, {\"index\": 2, \"class\": \"relationship\", \"text\": \"her heart aching for Romeo\", \"color\": \"#FEF0C3\", \"startPos\": 42, \"endPos\": 68, \"beforeText\": \"Lady Juliet gazed longingly at the stars, \", \"extractionText\": \"her heart aching for Romeo\", \"afterText\": \"\", \"attributesHtml\": \"<div><strong>class:</strong> relationship</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">type</span>: <span class=\\\"lx-attr-value\\\">affectionate longing</span>}</div>\"}, {\"index\": 3, \"class\": \"character\", \"text\": \"Romeo\", \"color\": \"#D2E3FC\", \"startPos\": 63, \"endPos\": 68, \"beforeText\": \"Lady Juliet gazed longingly at the stars, her heart aching for \", \"extractionText\": \"Romeo\", \"afterText\": \"\", \"attributesHtml\": \"<div><strong>class:</strong> character</div><div><strong>attributes:</strong> {<span class=\\\"lx-attr-key\\\">emotional_state</span>: <span class=\\\"lx-attr-value\\\">desired</span>}</div>\"}];\n",
225227
" let currentIndex = 0;\n",
226228
" let isPlaying = false;\n",
227229
" let animationInterval = null;\n",

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ dependencies = [
1818

1919
[dependency-groups]
2020
dev = [
21+
"jupyter>=1.1.1",
22+
"langextract[openai]>=1.0.9",
23+
"llama-cpp-python[server]>=0.3.16",
2124
"notebook>=7.4.5",
2225
"ruff>=0.12.12",
2326
]

0 commit comments

Comments
 (0)