Repository navigation
feat(models): type exchange info as Ask/PostExchangeInfo - #65
Merged
Merged
Conversation
The KE OpenAPI spec reports exchanges with ANSWER KIs as AskExchangeInfo (with the answered bindings) and with REACT KIs as PostExchangeInfo (with argument and result bindings), but we parsed both into a flat ExchangeInfo and dropped the bindings. Since KE 1.5.0 entries carry a knowledgeInteractionType discriminator and one ASK/POST result may mix both kinds. Older KEs omit it, so the subtype is inferred from the binding set fields, falling back to the result kind. Exchange info bindings stay raw: they follow the other KI's graph pattern. Closes #45 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #45
Why
The KE OpenAPI spec reports exchanges with ANSWER KIs as
AskExchangeInfo(with the answeredbindingSet) and exchanges with REACT KIs asPostExchangeInfo(withargumentBindingSet/resultBindingSet). We parsed both into a flatExchangeInfoand dropped the bindings.What
ke/models.py:AskExchangeInfoandPostExchangeInfosubclassExchangeInfo(so existingisinstance(info, ExchangeInfo)checks still work).AskResult/PostResult/ExchangeResult.exchange_infoare nowlist[AskExchangeInfo | PostExchangeInfo](exported asAnyExchangeInfo).The subtype is picked by a pydantic callable discriminator:
knowledgeInteractionType(AnswerKnowledgeInteraction/ReactKnowledgeInteraction). The KE only sends this after 1.5.0 (TNO/knowledge-engine@0ea958b), and from then on one ASK/POST result can mix both kinds because the reasoner combines KIs.examples/compose.yaml).AskExchangeInfo, POST →PostExchangeInfo.An unknown
knowledgeInteractionTyperaises aValidationError.Exchange info bindings stay raw
dict[str, str]: they follow the other KI's graph pattern, not the local binding model.FakeClientreturnsAskExchangeInfo(mocked bindings) for ASK andPostExchangeInfo(posted arguments + mocked results) for POST.README,
CONTEXT.mdand example 03 are updated.Testing
tests/test_client.py: parsing the ≤ 1.5.0 shape, the newer mixed discriminated shape, the POST fallback without binding sets, and rejection of unknown types.tests/test_ask_and_post.py: the subtypes and bindings from theFakeClient.uv run pytest tests/,ruff check,ruff format --checkpass; no new pyright errors.