Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
modified the prompt for titan express
Quick prompt fix for titan express model
  • Loading branch information
krishna999 authored Feb 22, 2024
commit 91e829e794fc583a2deccb5ca932ae1f3cbb38e7
13 changes: 11 additions & 2 deletions pca-server/src/pca/pca-aws-sf-summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,14 @@ def generate_bedrock_summary(transcript, api_mode):
result = {}
for item in templates:
key = list(item.keys())[0]

prompt = item[key]
# Quick fix for Titan
prompt = modify_prompt_based_on_model(BEDROCK_MODEL_ID, prompt)

if key == 'Summary' and SUMMARIZE_TYPE == 'BEDROCK+TCA' and api_mode == cf.API_ANALYTICS:
continue
else:
prompt = item[key]
else:
prompt = prompt.replace("{transcript}", transcript)
parameters = {
"temperature": 0
Expand All @@ -229,6 +233,11 @@ def generate_bedrock_summary(transcript, api_mode):
return json.dumps(result)
return json.dumps(result)

def modify_prompt_based_on_model(model_id, prompt):
if model_id == "amazon.titan-text-express-v1":
prompt = prompt.replace("Human:", "")
prompt = prompt.replace("Assistant:", "")
return prompt

def get_transcript_str(interimResultsFile):
payload = {
Expand Down