Azure OpenAi API - Java vs Python inconsistency

Jack Campbell 0 Reputation points

I using Azure openAI to create an artificial intelligence that creates JSON files. I originally wrote this in python but the requirements of the project changed requiring it to be in Java. Both have the same model and storage configuration but when testing with the same prompt, the python creates a JSON every time and the Java never has created one. I have checked and double checked every part of my program and they seem to be identical except for syntax. In debugging it seems like my system message is not being sent properly.

I would love to see the backend on the Azure side to see what it receives from me but I am unsure if that is possible. Any suggestions on how to debug or fix this inconsistency? Thank you!

Java code:

this.chatMessages = new ArrayList<>(); this.chatMessages.add(new ChatRequestSystemMessage(messageSystem));

this.chatMessages.add(new ChatRequestUserMessage(message));

this.searchConfiguration= new AzureSearchChatExtensionConfiguration(
new AzureSearchChatExtensionParameters(Chat.searchEndpoint, Chat.searchIndexName)
.setSemanticConfiguration(Chat.searchIndexName + "-semantic-configuration")
new AzureSearchIndexFieldMappingOptions()
.setAuthentication(new OnYourDataApiKeyAuthenticationOptions(Chat.searchKey))
.setEmbeddingDependency(new OnYourDataDeploymentNameVectorizationSource("text-embedding-ada-002"))

ChatCompletionsOptions options = new ChatCompletionsOptions(this.chatMessages)

this.currentResponse = this.openaiClient.getChatCompletions(Chat.openaiDeployment, options);

Python Code:

  self._message_history = [{"role": "system", "content": self._message_system}]

    self._message_history.append({"role": "user", "content": message})

    self._message_latest =
            "data_sources": [  
                    "type": "azure_search",
                    "parameters": {
                        "endpoint": self._search_endpoint,
                        "index_name": self._search_index_name,
                        "semantic_configuration": self._search_index_name + "-semantic-configuration",
                        "query_type": "vectorSemanticHybrid",
                        "fields_mapping": {
                            "content_fields_separator": "\n",
                            "content_fields": [
                            "filepath_field": "title",
                            "title_field": "file_name",
                            "url_field": "experiment_id",
                            "vector_fields": [
                        "in_scope": True,
                        "role_information": self._message_system,
                        "filter": None,
                        "strictness": 2,
                        "top_n_documents": 5,
                        "authentication": {
                            "type": "api_key",
                            "key": self._search_key
                        "embedding_dependency": {
                            "type": "deployment_name",
                            "deployment_name": "text-embedding-ada-002"
                        "key": self._search_key,
                        "indexName": self._search_index_name
Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
851 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,595 questions
0 comments No comments
{count} votes