Skip to content

Commit 792aa42

Browse files
committed
chore(deps): update invoke llm depending on the model used
1 parent 24816ae commit 792aa42

File tree

1 file changed

+13
-3
lines changed
  • samples/contract-compliance-analysis/back-end/stack/sfn/common-layer

1 file changed

+13
-3
lines changed

samples/contract-compliance-analysis/back-end/stack/sfn/common-layer/llm.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,19 @@ def invoke_llm(prompt, model_id, temperature=0.5, top_k=None, top_p=0.8, max_new
6060
response = chain.invoke({})
6161
content = response.content
6262

63+
usage_data = None
64+
stop_reason = None
65+
66+
if ('anthropic' in model_id):
67+
usage_data = response.response_metadata['usage']
68+
stop_reason = response.response_metadata['stop_reason']
69+
elif('amazon.nova' in model_id):
70+
usage_data = response.usage_metadata
71+
stop_reason = response.response_metadata['stopReason']
72+
6373
if verbose:
6474
logger.info(f"Model response: {content}")
65-
logger.info(f"Model usage: {response.response_metadata['usage']}")
66-
logger.info(f"Model stop_reason: {response.response_metadata['stop_reason']}")
75+
logger.info(f"Model usage: {usage_data}")
76+
logger.info(f"Model stop_reason: {stop_reason}")
6777

68-
return content, response.response_metadata['usage'], response.response_metadata["stop_reason"]
78+
return content, usage_data, stop_reason

0 commit comments

Comments
 (0)