chatomon.knowledge
¶
The knowledge an atom's nucleus draws from.
Classes:
| Name | Description |
|---|---|
Knowledge |
Plain-text knowledge added to a prompt in a delimited section. |
Knowledge
¶
Plain-text knowledge added to a prompt in a delimited section.
The same object can be given to the atom and, explicitly, to an orbital such as a judge: chatomon never shares it implicitly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The knowledge text. |
required |
title
|
str | None
|
Optional title rendered in the section header. |
None
|
Raises:
| Type | Description |
|---|---|
ChatomonConfigError
|
If |
Examples:
from chatomon import Knowledge
faq = Knowledge("Returns are accepted within 30 days.", title="FAQ")
assert faq.render().startswith('<knowledge title="FAQ">')
Methods:
| Name | Description |
|---|---|
from_file |
Read knowledge from a text file. |
render |
Render the knowledge as a delimited prompt section. |
Source code in src/chatomon/knowledge.py
35 36 37 38 39 | |
from_file
classmethod
¶
from_file(
path: str | PathLike[str],
*,
title: str | None = None,
encoding: str = "utf-8"
) -> Knowledge
Read knowledge from a text file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Path of the file. |
required |
title
|
str | None
|
Optional title rendered in the section header. |
None
|
encoding
|
str
|
File encoding. |
'utf-8'
|
Returns:
| Type | Description |
|---|---|
Knowledge
|
The knowledge. |
Raises:
| Type | Description |
|---|---|
OSError
|
If the file cannot be read. |
ChatomonConfigError
|
If the file is empty. |
Source code in src/chatomon/knowledge.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
render
¶
render() -> str
Render the knowledge as a delimited prompt section.
Returns:
| Type | Description |
|---|---|
str
|
The text wrapped in |
Source code in src/chatomon/knowledge.py
65 66 67 68 69 70 71 72 | |