update
This commit is contained in:
@@ -103,22 +103,22 @@ function formatLLMtext_phi4(name::T, text::T;
|
||||
formattedtext =
|
||||
if name == "system"
|
||||
"""
|
||||
<|im_start|>$name<|im_sep|>
|
||||
<|system|>
|
||||
$text
|
||||
<|im_end|>
|
||||
<|end|>
|
||||
"""
|
||||
else
|
||||
"""
|
||||
<|im_start|>$name<|im_sep|>
|
||||
<|assistant|>
|
||||
$text
|
||||
<|im_end|>
|
||||
<|end|>
|
||||
"""
|
||||
end
|
||||
|
||||
if assistantStarter
|
||||
formattedtext *=
|
||||
"""
|
||||
<|im_start|>assistant<|im_sep|>
|
||||
<|assistant|>
|
||||
"""
|
||||
end
|
||||
|
||||
|
||||
80
src/util.jl
80
src/util.jl
@@ -6,7 +6,7 @@ export timedifference, showstracktrace, findHighestIndexKey, uuid4snakecase, rep
|
||||
dfToString, dataframe_to_json_list, dictToString, dictToString_noKey,
|
||||
dictToString_numbering, extract_triple_backtick_text,
|
||||
countGivenWords, remove_french_accents, detect_keyword, extractTextBetweenCharacter,
|
||||
convertCamelSnakeKebabCase
|
||||
convertCamelSnakeKebabCase, fitrange, lastElementsIndex
|
||||
|
||||
using JSON3, DataStructures, Distributions, Random, Dates, UUIDs, MQTTClient, DataFrames
|
||||
|
||||
@@ -1134,14 +1134,80 @@ true
|
||||
````
|
||||
"""
|
||||
function issomething(x)
|
||||
return x === nothing ? false : true
|
||||
return x === nothing ? false : true
|
||||
end
|
||||
|
||||
|
||||
""" Adjust a given range to fit within the bounds of a vector's length.
|
||||
|
||||
# Arguments
|
||||
- `v::T1`
|
||||
the input vector to check against
|
||||
- `range::UnitRange`
|
||||
the original range to be adjusted
|
||||
|
||||
# Return
|
||||
- `adjusted_range::UnitRange`
|
||||
a range that is constrained to the vector's length, preventing out-of-bounds indexing
|
||||
|
||||
# Example
|
||||
|
||||
julia> v = [1, 2, 3, 4, 5]
|
||||
julia> fitrange(v, 3:10)
|
||||
3:5
|
||||
|
||||
"""
|
||||
function fitrange(v::T1, range::UnitRange) where {T1<:AbstractVector}
|
||||
totalelements = length(v)
|
||||
|
||||
startind =
|
||||
# check if user put start range greater than total event
|
||||
if range.start > totalelements
|
||||
totalelements
|
||||
else
|
||||
range.start
|
||||
end
|
||||
|
||||
stopind =
|
||||
if range.stop > totalelements
|
||||
totalelements
|
||||
else
|
||||
range.stop
|
||||
end
|
||||
|
||||
return startind:stopind
|
||||
end
|
||||
|
||||
|
||||
""" Find a unit range for a vector given a number of the most recent elements of interest.
|
||||
|
||||
# Arguments
|
||||
- `v::AbstractVector`
|
||||
the input vector to extract recent elements from
|
||||
- `n::Integer`
|
||||
the number of most recent elements to include in the range
|
||||
|
||||
# Return
|
||||
- `UnitRange`
|
||||
a range representing the last `n` elements of the vector
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
julia> a = [1, 2, 3, 4, 5]
|
||||
julia> lastElementsIndex(a, 3)
|
||||
3:5
|
||||
```
|
||||
"""
|
||||
function lastElementsIndex(v::AbstractVector, n::Integer)
|
||||
len = length(v)
|
||||
if n == 0
|
||||
return 1:len
|
||||
end
|
||||
|
||||
start = max(1, len - n + 1)
|
||||
return start:len
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end # module util
|
||||
Reference in New Issue
Block a user