API Reference¶
Auto-generated reference for the public hands_on_ai API, built from the
package's docstrings. For task-oriented walkthroughs, see the guides under
Learn; this page is the exhaustive symbol-level reference.
Package¶
hands_on_ai: Your Hands-on AI Toolkit
A modular toolkit for learning AI concepts through hands-on experimentation.
Chat¶
The chat module provides the high-level conversational API, the bot
personalities, and a stateful Conversation helper.
chat.get_response¶
Core response functionality for the chat module.
chat_completion
¶
Send a list of chat messages to the LLM and return (content, usage).
This is the low-level, multi-message primitive used by both
:func:get_response (single-turn) and :class:Conversation (multi-turn).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
list
|
OpenAI-style message dicts, e.g.
|
required |
model
|
str
|
LLM model to use (defaults to config setting). |
None
|
personality
|
str
|
Used to pick a fallback message during retries. |
'friendly'
|
stream
|
bool
|
Whether to request streaming output. |
False
|
retries
|
int
|
Number of attempts before giving up. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
|
|
|
Source code in src/hands_on_ai/chat/get_response.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
get_last_usage
¶
Return token usage from the most recent get_response/bot call (or None).
Source code in src/hands_on_ai/chat/get_response.py
32 33 34 | |
get_response
¶
Send a single prompt to the LLM and retrieve the model's response.
This is a stateless, single-turn helper: it sends exactly one system
message and one user message, with no memory of previous calls. For a
multi-turn chat that remembers history, use :class:Conversation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
The text prompt to send to the model |
required |
model
|
str
|
LLM model to use (defaults to config setting) |
None
|
system
|
str
|
System message defining bot behavior |
'You are a helpful assistant.'
|
personality
|
str
|
Used for fallback character during retries |
'friendly'
|
stream
|
bool
|
Whether to request streaming output (default False) |
False
|
retries
|
int
|
Number of times to retry on error |
2
|
return_usage
|
bool
|
If True, return |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
AI response or error message. If |
str
|
|
Source code in src/hands_on_ai/chat/get_response.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
set_stream_printing
¶
Enable or disable live token printing to stdout (used by the chat REPL).
Source code in src/hands_on_ai/chat/get_response.py
21 22 23 24 | |
stream_response
¶
Like :func:get_response, but yields the response in chunks as it arrives.
This lets you show text as the model generates it, instead of waiting for the whole answer:
for chunk in stream_response("Tell me a short story"):
print(chunk, end="", flush=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
The text prompt to send to the model. |
required |
model
|
str
|
LLM model to use (defaults to config setting). |
None
|
system
|
str
|
System message defining bot behavior. |
'You are a helpful assistant.'
|
personality
|
str
|
Unused here; kept for signature parity with get_response. |
'friendly'
|
retries
|
int
|
Unused here; streaming makes a single attempt. |
2
|
Yields:
| Name | Type | Description |
|---|---|---|
str |
Pieces of the response as they arrive. |
Source code in src/hands_on_ai/chat/get_response.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
chat.bots¶
Bot personality discovery and retrieval.
get_bot
¶
Retrieve a specific bot by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Bot name |
required |
Returns:
| Name | Type | Description |
|---|---|---|
function |
Bot function or None if not found |
Source code in src/hands_on_ai/chat/bots.py
31 32 33 34 35 36 37 38 39 40 41 | |
get_bot_description
¶
Get the first non-empty line of a bot's docstring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bot_func
|
function
|
Bot function |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Bot description |
Source code in src/hands_on_ai/chat/bots.py
44 45 46 47 48 49 50 51 52 53 54 55 56 | |
list_available_bots
¶
Discover available bot functions defined in personalities module. Bots must accept a single 'prompt' argument and not be private.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dictionary of bot names and functions |
Source code in src/hands_on_ai/chat/bots.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
chat.conversation¶
Multi-turn conversation memory for the chat module.
An LLM is stateless: each request only sees the messages you send it. To make a
bot that "remembers" earlier turns, you keep the running transcript and resend it
every time. Conversation does exactly that bookkeeping for you, so you can
focus on the conversation instead of the plumbing.
Example
from hands_on_ai.chat import Conversation chat = Conversation(system="You are a helpful tutor.") chat.ask("My name is Sam.") chat.ask("What's my name?") # remembers "Sam" print(chat.total_tokens) # tokens used across the whole chat
Conversation
¶
A stateful chat that remembers the conversation history.
Source code in src/hands_on_ai/chat/conversation.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
__init__
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
str
|
System message that defines the bot's behavior. |
'You are a helpful assistant.'
|
model
|
str
|
LLM model to use (defaults to config setting). |
None
|
personality
|
str
|
Used for fallback character during retries. |
'friendly'
|
Source code in src/hands_on_ai/chat/conversation.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
ask
¶
Send prompt as the next user turn and return the model's reply.
The user message and the reply are both appended to the history, so the next call automatically includes everything said so far.
Source code in src/hands_on_ai/chat/conversation.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
history
¶
Return the user/assistant turns (excluding the system message).
Source code in src/hands_on_ai/chat/conversation.py
75 76 77 | |
load
classmethod
¶
Recreate a conversation previously written with :meth:save.
Source code in src/hands_on_ai/chat/conversation.py
90 91 92 93 94 95 96 97 98 99 100 101 | |
reset
¶
Clear the conversation history, keeping the original system prompt.
Source code in src/hands_on_ai/chat/conversation.py
69 70 71 72 73 | |
save
¶
Save the conversation (system prompt, history, token total) to JSON.
Source code in src/hands_on_ai/chat/conversation.py
79 80 81 82 83 84 85 86 87 88 | |
RAG¶
Retrieval-augmented generation helpers — chunking, embedding, indexing, and similarity search.
rag.utils¶
Core RAG utilities for document loading, chunking, embedding, and retrieval.
chunk_text
¶
Split text into chunks of approximately equal size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
Text to chunk |
required | |
chunk_size
|
Words per chunk (default from config) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of text chunks |
Source code in src/hands_on_ai/rag/utils.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
copy_sample_docs
¶
Copy sample documents to a destination directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
Path to copy documents to (default: current directory) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path to the destination directory |
Source code in src/hands_on_ai/rag/utils.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
get_embeddings
¶
Get embeddings for text chunks using the OpenAI-compatible embeddings API.
This uses the same /v1 endpoint and client as the rest of the package,
so it works with any OpenAI-compatible provider (Ollama, OpenAI, etc.)
rather than only Ollama's native /api/embeddings endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
List of text chunks |
required | |
model
|
Embedding model to use (default from config) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
Array of embedding vectors |
Raises:
| Type | Description |
|---|---|
Exception
|
If embedding request fails |
Source code in src/hands_on_ai/rag/utils.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
get_sample_docs_path
¶
Get the path to the sample document directory.
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path object to the sample documents directory |
Source code in src/hands_on_ai/rag/utils.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
get_top_k
¶
Retrieve top k similar chunks for a query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
Search query |
required | |
index_path
|
Path to index file |
required | |
k
|
Number of results to return |
3
|
|
return_scores
|
Whether to include similarity scores |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of (chunk, source) tuples, optionally with scores |
Source code in src/hands_on_ai/rag/utils.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
list_sample_docs
¶
List all available sample documents.
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of sample document filenames |
Source code in src/hands_on_ai/rag/utils.py
183 184 185 186 187 188 189 190 191 | |
load_index_with_sources
¶
Load RAG index with source tracking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path to index file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(vectors, chunks, sources) |
Source code in src/hands_on_ai/rag/utils.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
load_text_file
¶
Load text from various file formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Extracted text content |
Raises:
| Type | Description |
|---|---|
ImportError
|
If required dependencies are missing |
ValueError
|
If file type is unsupported |
Source code in src/hands_on_ai/rag/utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
save_index_with_sources
¶
Save RAG index with source tracking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
Embedding vectors |
required | |
chunks
|
Text chunks |
required | |
sources
|
Source information for each chunk |
required | |
path
|
Path to save index file |
required |
Source code in src/hands_on_ai/rag/utils.py
109 110 111 112 113 114 115 116 117 118 119 | |
Agent¶
Tool-using agent core: register tools, list them, and run the agent loop.
agent.core¶
Core agent functionality for ReAct-style reasoning and tool use.
list_tools
¶
List all registered tools.
Returns:
| Name | Type | Description |
|---|---|---|
list |
List of tool information dictionaries |
Source code in src/hands_on_ai/agent/core.py
34 35 36 37 38 39 40 41 42 43 44 | |
register_tool
¶
Register a tool with the agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Tool name |
required |
description
|
str
|
Tool description |
required |
function
|
Callable
|
Tool function |
required |
Source code in src/hands_on_ai/agent/core.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
run_agent
¶
Run the agent with the given prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User question or instruction |
required |
model
|
Optional[str]
|
LLM model to use, defaults to configured model |
None
|
format
|
str
|
Format to use ("react", "json", or "auto") |
'auto'
|
max_iterations
|
int
|
Maximum number of tool use iterations |
5
|
verbose
|
bool
|
Whether to print intermediate steps |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Final agent response |
Source code in src/hands_on_ai/agent/core.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
Workflow¶
Multi-step pipeline runner for chaining steps together.
workflow.runner¶
A tiny file-based workflow runner: the Interpretable Context Methodology (ICM).
Instead of a coordination framework, a workflow is just a folder of numbered
stages. Each stage has a CONTEXT.md (its instructions) and an output/
folder. One orchestrating model reads each stage's instructions plus the
previous stage's output, and writes a new readable file. A human reviews (and
can edit) the output between stages.
workspace/
├── CONTEXT.md # optional: shared system prompt / overall goal
├── references/ # optional: stable rules (the "factory")
└── stages/
├── 01_research/
│ ├── CONTEXT.md # what this stage should do
│ └── output/ # output.md is written here
└── 02_draft/
├── CONTEXT.md
└── output/
Run one stage at a time and review the output file before continuing. This runner is deliberately sequential and human-in-the-loop, not an autonomous loop:
from hands_on_ai.workflow import Pipeline
pipe = Pipeline("workspace")
pipe.status() # show stages and which are done
pipe.run_next() # runs stage 01, writes output.md, stops for review
# ...open stages/01_research/output/output.md, edit if needed...
pipe.run_next() # runs stage 02 using stage 01's reviewed output
Pipeline
¶
Run a folder-based (ICM) workflow one reviewable stage at a time.
Source code in src/hands_on_ai/workflow/runner.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
reset
¶
Delete all stage outputs so the workflow can be re-run from the start.
Source code in src/hands_on_ai/workflow/runner.py
179 180 181 182 183 184 | |
run_all
¶
Run every remaining stage in order (no review pause between them).
Use this only once you trust the pipeline. The review-first run_next
is the recommended way to drive it. max_steps is a safety bound.
Source code in src/hands_on_ai/workflow/runner.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
run_next
¶
Run the next not-yet-completed stage, write its output, and stop.
This is the human-in-the-loop default: run one stage, then review (and
optionally edit) output/output.md before calling run_next again.
Returns:
| Type | Description |
|---|---|
|
dict with |
|
|
every stage is already done. |
Source code in src/hands_on_ai/workflow/runner.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
status
¶
Print and return [(stage_name, done), ...].
Source code in src/hands_on_ai/workflow/runner.py
133 134 135 136 137 138 | |
init_workspace
¶
Create a starter workspace with numbered stage folders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Directory to create the workspace in. |
required | |
stages
|
List of stage names, e.g. |
required | |
system
|
str
|
Optional shared instruction written to the workspace |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
the workspace root. |
Source code in src/hands_on_ai/workflow/runner.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
Evaluation¶
LLM-as-judge scoring for bot outputs.
eval.judge¶
LLM-as-judge: ask a language model to score an output against criteria.
This is how a lot of modern AI evaluation works: instead of hand-writing graders, you ask a capable model to score a response. It is fast and flexible, but not infallible, so treat the score as a signal, not a verdict.
judge
¶
Ask an LLM to score output against criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
The text to evaluate. |
required | |
criteria
|
What "good" means here (e.g. "accurate, concise, and friendly"). |
required | |
question
|
The original question the output answers (optional context). |
None
|
|
model
|
LLM model to use (defaults to config). |
None
|
|
scale
|
Top of the scoring scale (default 5; 1 is worst). |
5
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
|
Source code in src/hands_on_ai/eval/judge.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
Core utilities¶
Shared configuration, model discovery, and response caching used across the toolkit.
config¶
Shared configuration for all hands-on-ai modules. Handles server settings, paths, and fallback messages.
ensure_config_dir
¶
Create config directory if it doesn't exist.
Source code in src/hands_on_ai/config.py
30 31 32 | |
get_api_key
¶
Get the API key from config if available.
Source code in src/hands_on_ai/config.py
164 165 166 | |
get_chunk_size
¶
Get the default chunk size from config.
Source code in src/hands_on_ai/config.py
159 160 161 | |
get_embedding_model
¶
Get the default embedding model from config.
Source code in src/hands_on_ai/config.py
154 155 156 | |
get_model
¶
Get the default model from config.
Source code in src/hands_on_ai/config.py
149 150 151 | |
get_server_url
¶
Get the server URL from config.
Source code in src/hands_on_ai/config.py
144 145 146 | |
load_config
¶
Load configuration from config file or environment variables.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Configuration settings |
Source code in src/hands_on_ai/config.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
load_default_config
¶
Load the default configuration packaged with HandsOnAI.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Default configuration settings |
Source code in src/hands_on_ai/config.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
load_fallbacks
¶
Load fallback personality messages from user, local, or default locations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
str
|
Module name to load fallbacks for |
'chat'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Fallback messages by personality |
Source code in src/hands_on_ai/config.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
save_config
¶
Save configuration to config file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict
|
Configuration settings to save |
required |
Source code in src/hands_on_ai/config.py
97 98 99 100 101 102 103 104 105 106 107 108 109 | |
models¶
Core model utilities for Hands-on AI.
This module provides centralized functionality for working with LLM models: - Listing available models - Checking if a model exists - Getting model information - Normalizing model names - Detecting model capabilities
check_model_exists
¶
Check if a model exists on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Name of the model |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the model exists, False otherwise |
Source code in src/hands_on_ai/models.py
92 93 94 95 96 97 98 99 100 101 102 | |
detect_best_format
¶
Determine the best format for the given model based on its capabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Name of the model |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
"react" or "json" (default) |
Source code in src/hands_on_ai/models.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
get_model_capabilities
¶
Determine the capabilities of a given model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Name of the model |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, bool]
|
Dict[str, bool]: Dictionary of capability flags |
Source code in src/hands_on_ai/models.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
get_model_info
¶
Check if a model exists using OpenAI-compatible endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Name of the model |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Optional[Dict]: Basic model information or None if not found |
Source code in src/hands_on_ai/models.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
list_models
¶
List all available models using OpenAI-compatible endpoint.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict]: List of model information dictionaries |
Source code in src/hands_on_ai/models.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
normalize_model_name
¶
Normalize the model name to the format expected by Ollama.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Original model name |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Normalized model name |
Source code in src/hands_on_ai/models.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
cache¶
Optional on-disk response cache.
Caching is off by default. Enable it by setting the HANDS_ON_AI_CACHE
environment variable to a directory:
export HANDS_ON_AI_CACHE=~/.hands-on-ai/cache
When enabled, :func:hands_on_ai.chat.get_response returns a saved answer for an
identical (model, system, prompt) instead of calling the model again. This is
useful in classrooms: reruns are reproducible, repeated calls cost nothing, and a
warmed cache works offline.
The cache is intentionally simple: one plain-text file per entry, named by a hash of the inputs. Delete the directory to clear it.
cache_dir
¶
Return the cache directory as a Path if caching is enabled, else None.
Source code in src/hands_on_ai/cache.py
24 25 26 27 | |
get
¶
Return a cached response string, or None on a miss (or when disabled).
Source code in src/hands_on_ai/cache.py
35 36 37 38 39 40 41 | |
put
¶
Store a response in the cache. No-op when caching is disabled.
Source code in src/hands_on_ai/cache.py
44 45 46 47 48 49 50 | |