-
Notifications
You must be signed in to change notification settings - Fork 8
/
PromptingTools.jl
96 lines (78 loc) · 2.51 KB
/
PromptingTools.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
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
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
module PromptingTools
import AbstractTrees
using Base64: base64encode
import Dates
using Dates: now, DateTime, @dateformat_str
using Logging
using OpenAI
using JSON3
using JSON3: StructTypes
using HTTP
import Preferences
using Preferences: @load_preference, @set_preferences!
using PrecompileTools
using Test, Pkg
# GLOBALS and Preferences are managed by Preferences.jl - see src/preferences.jl for details
"The following keywords are reserved for internal use in the `ai*` functions and cannot be used as placeholders in the Messages"
const RESERVED_KWARGS = [
:http_kwargs,
:api_kwargs,
:conversation,
:return_all,
:dry_run,
:image_url,
:image_path,
:image_detail,
:model
]
# export replace_words, recursive_splitter, split_by_length, call_cost, auth_header # for debugging only
# export length_longest_common_subsequence, distance_longest_common_subsequence
# export pprint
include("utils.jl")
export aigenerate, aiembed, aiclassify, aiextract, aiscan, aiimage
# export render # for debugging only
include("llm_interface.jl")
# sets up the global registry of models and default model choices
include("user_preferences.jl")
## Conversation history / Prompt elements
export AIMessage
# export UserMessage, UserMessageWithImages, SystemMessage, DataMessage # for debugging only
include("messages.jl")
export aitemplates, AITemplate
include("templates.jl")
const TEMPLATE_PATH = String[joinpath(@__DIR__, "..", "templates")]
const TEMPLATE_STORE = Dict{Symbol, Any}()
const TEMPLATE_METADATA = Vector{AITemplateMetadata}()
# export save_conversation, load_conversation, save_template, load_template
include("serialization.jl")
## Utilities to support structured extraction
include("extraction.jl")
## Utilities to support code generation
# Not export extract_code_blocks, extract_function_name
include("code_parsing.jl")
include("code_expressions.jl")
export AICode
include("code_eval.jl")
## Individual interfaces
include("llm_shared.jl")
include("llm_openai.jl")
include("llm_ollama_managed.jl")
include("llm_ollama.jl")
include("llm_google.jl")
include("llm_anthropic.jl")
include("llm_sharegpt.jl")
include("llm_tracer.jl")
## Convenience utils
export @ai_str, @aai_str, @ai!_str, @aai!_str
include("macros.jl")
## Experimental modules
include("Experimental/Experimental.jl")
function __init__()
# Load templates
load_templates!()
end
# Enable precompilation to reduce start time, disabled logging
with_logger(NullLogger()) do
@compile_workload include("precompilation.jl")
end
end # module PromptingTools