Skip to content

Commit

Permalink
improve response data structure to accomodate for generic and openai …
Browse files Browse the repository at this point in the history
…assistant engines
  • Loading branch information
valeksiev committed Dec 12, 2024
1 parent 48c5f6c commit 247bc3e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions alkemio_virtual_contributor_engine/events/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ def __init__(self, response: Optional[Dict[str, Any]] = None):
if response is not None:
try:
self.result = response["result"]
self.human_language = response["human_language"]
self.result_language = response["result_language"]
self.knowledge_language = response["knowledge_language"]
self.original_result = response["original_result"]
self.human_language = response.get("human_language", "")
self.result_language = response.get("result_language", "")
self.knowledge_language = response.get("knowledge_language", "")
self.original_result = response.get(
"original_result", response["result"]
)
self.sources = [
Source(source) for source in response.get("sources", [])
]
Expand All @@ -74,5 +76,5 @@ def to_dict(self):
"knowledgeLanguage": self.knowledge_language,
"originalResult": self.original_result,
"sources": list(map(lambda source: source.to_dict(), self.sources)),
"thread_id": self.thread_id,
"threadId": self.thread_id,
}

0 comments on commit 247bc3e

Please sign in to comment.