I am making the same call to Azure Open AI using the Java and Python APIs, and receiving very different results.
I am supplying a worked example
User Prompt
The following text is a customer complaint about Cheque In. Your task is to summarise your understanding of what the customer complaint was about in a few sentences.
<<<COMPLAINT>>>
I received a check from NS&I for £425 and tried to upload it using the check system on my online account but your system does not accept checks from the government there, I now have to drive 16 miles pay for parking ti the nearest Big Bank bank !! All because your system does not accept government checks !!!!!
Always follow these guidelines in your response:
<<<GUIDELINES>>>
* Start with "I understand that…".
* DO NOT include anything beyond your summary.
* Always use active voice.
* Always address the customer directly using "you".
* Refer to the bank as "we" and refer to any human advisor or agent as a colleague.
* Be clear, polite, and use language that is easy to understand.
* NEVER include any details about internal bank processes or systems, instead say "our records".
* Only use facts from the provided context. DO NOT make up information.
* This task is VERY sensitive; you MUST NOT make mistakes.
* DO NOT mention account markers.
* Always format monetary values as £x,xxx.xx.
* Use “day month year” format for dates e.g 22 May 2023
* Only use the last 4 digits of account numbers.
* Always use British spelling, NOT American.
System Prompt
You are a complaint handler for a customer service department at Big Bank
Python Code
from dotenv import load_dotenv
import os, sys
import jwt
import openai
from msal import ConfidentialClientApplication
from openai import AzureOpenAI
def get_jwt_token():
# org_constants
auth = os.getenv("MS_AUTH_URL")
# Provide Azure Client/App ID and Secret to Variables
client_secret = os.getenv("AZURE_CLIENT_SECRET")
client_id = os.getenv("AZURE_CLIENT_ID")
scope_list = [client_id + "/.default"]
# Getting JWT Token Using MSAL Methods for OpenAI Authentication
app = ConfidentialClientApplication(client_id=client_id, client_credential=client_secret, authority=auth)
result = app.acquire_token_for_client(scopes=scope_list)
return result.get("access_token")
api_base_full_chat = os.getenv("API_BASE_FULL_CHAT")
deployment_model_chat = os.getenv("DEPLOYMENT_MODEL_CHAT")
api_version_chat = os.getenv("AZURE_OPENAI_API_VERSION")
def create_chat_client():
client_chat = AzureOpenAI(
api_key=get_jwt_token(),
azure_deployment=deployment_model_chat,
azure_endpoint=api_base_full_chat,
api_version=api_version_chat,
)
return client_chat
chat = create_chat_client()
response = chat.chat.completions.create(
model=deployment_model_chat,
messages=[
{"role": "system", "content": "You are a complaint handler for a customer service department at Big Bank"},
{"role": "user", "content": user_prompt},
]
)
print(response.choices[0].message.content)
Java Code
this.setEnvironmnet();
//Get JWT
String auth = String.format("%s/%s", "https://login.microsoftonline.com", System.getProperty("AZURE_TENANT_ID"));
IClientSecret mySecret = ClientCredentialFactory.createFromSecret(System.getProperty("AZURE_CLIENT_SECRET"));
ConfidentialClientApplication app = ConfidentialClientApplication.builder(System.getProperty("AZURE_CLIENT_ID"), mySecret)
.authority(auth)
.proxy(getProxy())
.build();
Set<String> scopes = new HashSet<>();
scopes.add(String.format("%s/.default", System.getProperty("AZURE_CLIENT_ID")));
ClientCredentialParameters params = ClientCredentialParameters.builder(scopes).build();
IAuthenticationResult result = app.acquireToken(params).get(5000, TimeUnit.MILLISECONDS);
//Add JWT to header - get a 401 if try to use TokenCredential!
ClientOptions options = new ClientOptions();
List<Header> headers = new ArrayList<>();
headers.add(new Header("Authorization", String.format("Bearer %s", result.accessToken())));
options.setHeaders(headers);
//get client
OpenAIClient client = new OpenAIClientBuilder()
.clientOptions(options)
// .credential(this.getToken())
.endpoint(System.getProperty("AZURE_GPT4O_URL"))
.buildClient();
//Build and submit Prompt
List<ChatRequestMessage> chatMessages = new ArrayList<>();
chatMessages.add(new ChatRequestSystemMessage(this.getUnderstandingSystemPrompt()));
chatMessages.add(new ChatRequestUserMessage(this.getUnderstandingUserPrompt()));
ChatCompletionsOptions chatOptions = new ChatCompletionsOptions(chatMessages);
ChatCompletions response = this.getClient().getChatCompletions("gpt4o_2024-05-13", chatOptions);
response.getChoices().forEach(message -> {
System.out.println(message.getMessage().getContent());
});
Python Results
I understand that you received a cheque for £425.00 from NS&I and tried to upload it using our cheque system on your online account. Your complaint is that our system does not accept government cheques, which now requires you to drive 16 miles and pay for parking to visit the nearest Big Bank branch.
Java Results
Dear Customer,
Thank you for reaching out to us. I understand your frustration regarding the check deposit issue involving the sum of $425. Please accept my sincere apologies for the inconvenience this has caused you.
From your message, it appears that you were trying to upload a check using the online system but encountered a problem since our system does not support checks from the government. This has now left you in a situation where you need to drive 16 miles to our nearest branch for parking, which adds to your frustration.
Please allow me to address your concerns systematically:
-
Understanding the Issue:
- We understand that you received a check from the government and attempted to upload it using our online check system.
- The system currently does not accept government-issued checks, causing you to resort to visiting a branch in person.
-
Customer Experience:
- Your inconvenience in driving a significant distance to visit a branch is duly noted. We empathize with the unexpected trouble this has caused you.
Moving forward, here’s what we can do to assist you:
-
Alternative Submission:
- You can consider mailing the check to your branch. If you prefer this option, please let us know so we can provide you with the necessary details and ensure a prompt processing and response time.
-
Feedback to Improve:
- Your feedback will be forwarded to our IT and service teams to evaluate the possibility of including government-issued checks in the online check-processing system.
-
Compensation for Inconvenience:
- We would like to offer you a small compensation for your inconvenience. Please provide us with your mailing address, and we will send you a reimbursement for your travel expenses.
-
Personal Assistance:
- If there are any other specific needs or assistance you require, please do not hesitate to let us know. We are here to help you.
Once again, I apologize for the inconvenience and appreciate your understanding and patience as we work to resolve this issue. Thank you for banking with us, and we look forward to providing you with better services in the future.
Sincerely,
[Your Name]
Customer Service Department
Big Bank
As you can see the user prompt appears to be largely ignored in the Java version – any help appreciated
1