-
-
Notifications
You must be signed in to change notification settings - Fork 34
Add dictionaries as parameters for LLMFunctions #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dictionaries as parameters for LLMFunctions #113
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #113 +/- ##
==========================================
+ Coverage 43.49% 44.22% +0.73%
==========================================
Files 67 68 +1
Lines 476 484 +8
==========================================
+ Hits 207 214 +7
- Misses 269 270 +1
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic job @Seb-Ltz, only had some minor thoughts! 🚀
Tests/SpeziLLMTests/LLMOpenAIFunctionCallingParameterDSLTests+Dictionary.swift
Outdated
Show resolved
Hide resolved
Sources/SpeziLLMOpenAI/FunctionCalling/LLMFunctionParameterWrapper+DictionaryTypes.swift
Show resolved
Hide resolved
Thank you @philippzagar for the PR review! 🚀 |
Add dictionaries as parameters for LLMFunctions
♻️ Current situation & Problem
While developing test
LLMFunctions
, I discovered that Swift dictionaries are currently unsupported by SpeziLLM unless a custom parameter type is defined manually.To simplify this, this PR proposes adding support for dictionary types in
@Parameter
declarations, allowing to write:without needing to create a custom type for a dictionary.
⚙️ Release Notes
This PR adds support for the following Swift dictionary types as LLMFunction parameters, using Swift's standard type protocols (except for
Bool
):[String: Int]
dictionaries[String: Double (or Float)]
dictionaries[String: Bool]
dictionaries[String: String]
dictionariesEach dictionary is represented as a JSON Schema
object
, with the corresponding value type defined underadditionalProperties
.📚 Documentation
Documentation has been added.
✅ Testing
Unit tests have been written, following a similar structure than the unit tests for the array parameters.
Furthermore, all 4 dictionary types implemented (
string
,number
,integers
,bools
) have been tested manually, using some testLLMFunction
s and OpenAI's completion and Realtime API.📝 Code of Conduct & Contributing Guidelines
By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: