Skip to content

Commit bad911f

Browse files
authored
Merge pull request #736 from writer/dev
chore: Merge for release
2 parents 4b900a2 + 2c1c965 commit bad911f

File tree

191 files changed

+7721
-1421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+7721
-1421
lines changed

.github/workflows/ci-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: macos-latest-large
1515
strategy:
1616
matrix:
17-
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
17+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
1818

1919
steps:
2020
- uses: actions/checkout@v4

.github/workflows/ci-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: windows-latest
1515
strategy:
1616
matrix:
17-
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
17+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
1818

1919
steps:
2020
- uses: actions/checkout@v4

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
17+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
1818

1919
steps:
2020
- uses: actions/checkout@v4

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Pull requests should be done on the `dev` branch. When the release is finalised,
2525

2626
Whether you're interested in contributing to the repository, creating a fork, or just improving your understanding of Writer Framework, these are the suggested steps for setting up a development environment.
2727

28-
- You can install the package in editable mode using `poetry install`
28+
- You can install the package in editable mode using `poetry install --with build`
2929
- Enable the virtual environment with `poetry shell`
3030
- Install all the dev dependencies with `alfred install.dev`
3131
- Run Writer Framework on port 5000. For example, `writer edit apps/hello --port 5000`.

alfred/install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
def install_dev():
66
alfred.run("poetry install --with build")
77
alfred.run("npm ci")
8-
alfred.invoke_command("npm.codegen")
8+
alfred.run("npm run build")
99

1010
@alfred.command("install.ci", help="install ci dependencies and generate code", hidden=True)
1111
def install_ci():
1212
alfred.run("npm ci")
13-
alfred.invoke_command("npm.codegen")
13+
alfred.run("npm run build")

docs/framework/ai-module.mdx

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Function tools require the following properties:
217217

218218
When a conversation involves a tool (either a graph or a function), Framework automatically handles the requests from LLM to use the tools during interactions. If the tool needs multiple steps (for example, querying data and processing it), Framework will handle those steps recursively, calling functions as needed until the final result is returned.
219219

220-
By default, to prevent endless recursion, Framework will only handle 3 consecutive tool calls. You can expand it in case it doesn't suit your case – both `complete()` and `stream_complete()` accept a `max_tool_depth` parameter, which configures the maximum allowed recursion depth:
220+
By default, to prevent endless recursion, Framework will only handle 5 consecutive tool calls. You can expand it in case it doesn't suit your case – both `complete()` and `stream_complete()` accept a `max_tool_depth` parameter, which configures the maximum allowed recursion depth:
221221

222222
```python
223223
response = conversation.complete(tools=tool, max_tool_depth=7)
@@ -340,3 +340,84 @@ for chunk in stream_ask(
340340
```
341341
</CodeGroup>
342342

343+
## Using the `Tools` class
344+
345+
<Note>
346+
This document outlines the use of `Tools` in the Writer Framework; for more thorough documentation, check out (this guide)[https://dev.writer.com/api-guides/tools].
347+
</Note>
348+
349+
The `writer.ai.tools` instance provides access to Writer SDK `tools` resources, such as text splitting, medical content comprehension, and PDF parsing. Below is a guide on how to use each method.
350+
351+
### Splitting Content
352+
353+
The `split` method divides text into chunks based on a selected strategy.
354+
355+
```python
356+
from writer.ai import tools
357+
358+
content = \
359+
"""
360+
This is a long piece of text that needs to be split into smaller parts.
361+
Lorem ipsum dolor sit amet...
362+
"""
363+
chunks = tools.split(content, strategy="llm_split")
364+
print(chunks)
365+
```
366+
367+
**Parameters**:
368+
- `content` (str): The text to be split.
369+
- `strategy` (str): The splitting strategy (`llm_split`, `fast_split`, or `hybrid_split`).
370+
371+
**Returns**:
372+
A list of text chunks.
373+
374+
### Medical Content Comprehension
375+
376+
The `comprehend_medical` method processes medical text and extracts relevant entities based on a specified response type.
377+
378+
```python
379+
from writer.ai import tools
380+
381+
medical_text = "Patient shows symptoms of hypertension and diabetes."
382+
entities = tools.comprehend_medical(medical_text, response_type="Entities")
383+
print(entities)
384+
```
385+
386+
**Parameters**:
387+
- `content` (str): The medical text to process.
388+
- `response_type` (str): The type of medical response (`Entities`, `RxNorm`, `ICD-10-CM`, or `SNOMED CT`).
389+
390+
**Returns**:
391+
A list of extracted medical entities.
392+
393+
### PDF Parsing
394+
395+
The `parse_pdf` method extracts text content from a PDF file. The file can be referenced by its ID, or provided as a `File` object.
396+
397+
<CodeGroup>
398+
```python file_id
399+
from writer.ai import tools
400+
401+
file_id = "example-file-id"
402+
parsed_content = tools.parse_pdf(file_id, format="text")
403+
print(parsed_content)
404+
```
405+
```python upload_file
406+
from writer.ai import tools
407+
408+
file_object = upload_file(
409+
data=pdf_content,
410+
type="application/pdf",
411+
name="uploaded_file.pdf"
412+
)
413+
parsed_content = tools.parse_pdf(file_object, format="text")
414+
print(parsed_content)
415+
```
416+
</CodeGroup>
417+
418+
**Parameters**:
419+
- `file_id_or_file` (str or File): The file to parse (by ID or as an object).
420+
- `format` (str): The format of the extracted content (`text` or `markdown`).
421+
422+
**Returns**:
423+
The text content of the PDF.

0 commit comments

Comments
 (0)