Skip to content

Commit

Permalink
Added response metadata capture to trace directory
Browse files Browse the repository at this point in the history
  • Loading branch information
devjpt23 committed Sep 18, 2024
1 parent 78b92f8 commit 3996321
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kai/kai_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ def llm_result(
with open(result_file_path, "w") as f:
f.write(result.pretty_repr())

@enabled_check
def metadata(
self, current_batch_count:int, retry_count: int, metadata: dict
):
metadata_file_path = os.path.join(
self.trace_dir, f"{current_batch_count}", f"{retry_count}", "response_metadata.json"
)
os.makedirs(os.path.dirname(metadata_file_path), exist_ok=True)
with open(metadata_file_path,"w") as f:
f.write(json.dumps(metadata, indent=4))

@enabled_check
def exception(
self,
Expand Down
2 changes: 2 additions & 0 deletions kai/service/kai_application/kai_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ def get_incident_solutions_for_file(
f'{file_name.replace("/", "-")}',
):
llm_result = self.model_provider.llm.invoke(prompt)
meta_data = llm_result.response_metadata
trace.llm_result(count, retry_attempt_count, llm_result)
trace.metadata(count, retry_attempt_count, meta_data)

content = parse_file_solution_content(
src_file_language, str(llm_result.content)
Expand Down

0 comments on commit 3996321

Please sign in to comment.