All notable changes to HandyLLM will be documented in this file.
The format is based on Keep a Changelog.
- fix DictProxy YAML dump
- fix tool calls in stream mode: missing last tool call
- change import behavior:
__init__.py
:- use explicit imports instead of
*
- limit imports from
utils.py
- remove all imports from
response.py
andtypes.py
(please import them directly)
- use explicit imports instead of
response.py
: add missing items to__all__
- add
py.typed
for better IDE support
- 🔧 add lint dependency ruff
- add
scripts/lint.sh
for linting - add
scripts/format.sh
for formatting, and format all files - add CI test workflow
- add
- fix errors reported by ruff (E711, E722, F541)
- fix TypeError on python 3.8 ('type' object is not subscriptable)
Check 🌟s for attractive new features!
hprompt.py
:- 🌟
image_url
in chat hprompt file now supports local path (file://), both absolute and relative - 🌟 add
fetch()
,afetch()
,stream()
andastream()
methods for direct and typed API responses - add
RunConfig.var_map_file_format
for specifying variable map file format, including JSON / YAML;load_var_map()
supports format param
- 🌟
requestor.py
:- 🌟 add
fetch()
,afetch()
,stream()
andastream()
methods for typed API responses - use generic and add
DictRequestor
,BinRequestor
,ChatRequestor
andCompletionsRequestor
- 🌟 add
OpenAIClient
:- 🌟 constructor supports
endpoint_manager
,endpoints
andload_path
param; supports loading from YAML file andMapping
obj - APIs support
endpoints
param - APIs
endpoint
param supportsMapping
type
- 🌟 constructor supports
- 🌟 added
cache_manager.py
:CacheManager
for general purpose caching to text files- add
load_method
anddump_method
params - infers format from file suffix when convert handler is not provided
- add
- 🌟 added
response.py
:DictProxy
for quick access to well-defined response dict EndpointManager
: supports loading from YAML file usingendpoints
key, or fromIterable
obj__init__.py
import everything from hprompt for convenience- rename
_types.py
totypes.py
and expose all definitions prompt_converter.py
:- add generator sink
consume_stream2fd()
- add generator sink
utils.py
:- add generator filter
trans_stream_chat()
, generator sinkecho_consumer()
- add generator filter
- a lot improved type hints
- added tests:
- load prompt type specification
- variable map substitution
- ChatPrompt and CompletionsPrompt's API calls, supports for RunConfig.on_chunk, and addition operations
- chat hprompt
image_url
OpenAIClient
loading, chatfetch()
&stream()
endpoint_manager.py
cache_manager.py
- audio speech
- legacy OpenAIAPI
hprompt.py
:- add 'endpoints' to default record blacklist
- remove the
var_map
related configurations from the evaluated prompt, as it is already applied
EndpointManager
:- raises ValueError when getting endpoint out of empty
hprompt.py
: 'type' object is not subscriptable on python 3.8
prompt_converter.py
: removestream_msgs2raw()
andastream_msgs2raw()
as no longer needed
hprompt
: load methods now supportcls
parameter for prompt type specificationChatPrompt
andCompletionsPrompt
support optional request and metaChatPrompt
:- supports add dict
- add
add_message(...)
method
CompletionsPrompt
:- add
add_text(...)
method
- add
PromptConverter
:yaml.dump
usesallow_unicode=True
option- move all type definitions to
_types.py
- support for package development:
- add
requirement.txt
for development - add
scripts/test.sh
for running tests - add test scripts in
tests
folder
- add
HandyPrompt.eval(...)
should not make directories for output pathsCompletionsPrompt._run_with_client(...)
: misplacedrun_config
paramPromptConverter
- fix variable replacement for
content_array
message - fix wrong return type of
stream_msgs2raw
andastream_msgs2raw
- fix variable replacement for
requestor
:httpx.Response
should usereason_phrase
to get error reasonacall()
fix missing brackets for await_call_raw()
and_acall_raw()
intercept and raise new exception without original one_acall_raw()
: read the response first to preventhttpx.ResponseNotRead
before getting error message
_utils.exception2err_msg(...)
should append error message instead of printing- change
io.IOBase
toIO[str]
for file descriptors (e.g.RunConfig.output_fd
) - fix other type hints
- move all old files in
tests
folder toexamples
folder
- fix the debug print issue when outputting to a file in stream mode
- CLI: output to stderr without buffering
- add
RunConfig.output_path_buffering
for controlling buffering of output file - add this changelog
- fix
_post_check_output(...)
not using evaluatedrun_config
(may causeoutput_path
oroutput_fd
to be ignored)
- rename internal constants to remove leading
_
ofAPI_xxx
constants
- remove unused files in
deprecated
folder
- add
RunConfig.on_chunk
as callback for streamed chunks - add Azure tts example
- add
VM
method to transform kwargs to % wrapped variable map dict - add
var_map
arg toeval(...)
,run(...)
andarun(...)
for convenience
- merging different versions of
var_map
from method argument or from anotherRunConfig
, instead of replacing it as a whole - rename
RunConfig.to_dict
'sretain_fd
arg toretain_object
OpenAIClient
add audio speech (tts) api support- add azure support for audio speech and transcriptions
- add tts test script
- prioritize
RunConfig.output_evaled_prompt_fd
overRunConfig.output_evaled_prompt_path
eval(...)
- always return a new object
- gives
run_config
arg a default value - accepts kwargs, same as
run(...)
- when dumping, always filter request
- credential file do not overwrite existing request args
- non-stream mode prioritize
RunConfig.output_fd
overRunConfig.output_path