Skip to content

Commit 590d587

Browse files
committed
added cognitive search tracing enabled option
1 parent 8cc1958 commit 590d587

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

app/backend/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@
6666
<artifactId>azure-storage-blob</artifactId>
6767
</dependency>
6868

69-
<dependency>
70-
<groupId>com.microsoft.semantic-kernel</groupId>
71-
<artifactId>semantickernel-core</artifactId>
72-
<version>0.2.6-alpha</version>
73-
</dependency>
7469
</dependencies>
7570

7671
<build>

app/backend/src/main/java/com/microsoft/openai/samples/rag/ask/approaches/RetrieveThenReadApproach.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public RAGResponse run(String question, RAGOptions options) {
5959

6060
Completions completionsResults = openAIProxy.getCompletions(completionsOptions);
6161

62-
logger.debug("Completion generated with Prompt Tokens[{}], Completions Tokens[{}], Total Tokens[{}]",
62+
logger.info("Completion generated with Prompt Tokens[{}], Completions Tokens[{}], Total Tokens[{}]",
6363
completionsResults.getUsage().getPromptTokens(),
6464
completionsResults.getUsage().getCompletionTokens(),
6565
completionsResults.getUsage().getTotalTokens());

app/backend/src/main/java/com/microsoft/openai/samples/rag/chat/approaches/ChatReadRetrieveReadApproach.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public RAGResponse run(ChatGPTConversation conversation, RAGOptions options) {
5757
// STEP 3: Generate a contextual and content specific answer using the search results and chat history
5858
ChatCompletions chatCompletions = openAIProxy.getChatCompletions(chatCompletionsOptions);
5959

60-
logger.debug("Chat completion generated with Prompt Tokens[{}], Completions Tokens[{}], Total Tokens[{}]",
60+
logger.info("Chat completion generated with Prompt Tokens[{}], Completions Tokens[{}], Total Tokens[{}]",
6161
chatCompletions.getUsage().getPromptTokens(),
6262
chatCompletions.getUsage().getCompletionTokens(),
6363
chatCompletions.getUsage().getTotalTokens());

app/backend/src/main/java/com/microsoft/openai/samples/rag/config/CognitiveSearchConfiguration.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.azure.search.documents.SearchClientBuilder;
1010
import org.springframework.beans.factory.annotation.Autowired;
1111
import org.springframework.beans.factory.annotation.Value;
12+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
1213
import org.springframework.context.annotation.Bean;
1314
import org.springframework.context.annotation.Configuration;
1415
import org.springframework.context.annotation.Profile;
@@ -21,9 +22,10 @@ public class CognitiveSearchConfiguration {
2122

2223
@Autowired
2324
TokenCredential tokenCredential;
24-
@Profile("dev")
25+
2526
@Bean
26-
public SearchClient debugEnabledClient() {
27+
@ConditionalOnProperty(name = "openai.tracing.enabled", havingValue = "true")
28+
public SearchClient tracingEnabledClient() {
2729
String endpoint = "https://%s.search.windows.net".formatted(searchServiceName);
2830

2931
var httpLogOptions = new HttpLogOptions();
@@ -41,7 +43,7 @@ public SearchClient debugEnabledClient() {
4143

4244

4345
@Bean
44-
@Profile("default")
46+
@ConditionalOnProperty(name = "openai.tracing.enabled", havingValue = "false")
4547
public SearchClient productionEnabledClient() {
4648
String endpoint = "https://%s.search.windows.net".formatted(searchServiceName);
4749
return new SearchClientBuilder()

app/backend/src/main/resources/application.properties

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ openai.tracing.enabled=${AZURE_OPENAI_TRACING_ENABLED:false}
88

99
cognitive.search.service=${AZURE_SEARCH_SERVICE:gptkb-hxy5hdyir5eaa}
1010
cognitive.search.index=${AZURE_SEARCH_INDEX:gptkbindex}
11+
cognitive.tracing.enabled=${AZURE_SEARCH_TRACING_ENABLED:false}
12+
1113

1214
storage-account.service=${AZURE_STORAGE_ACCOUNT:sthxy5hdyir5eaa}
1315
blob.container.name=${AZURE_STORAGE_CONTAINER:content}

app/start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ echo ""
4343

4444
cd ../backend
4545
xdg-open http://localhost:8080
46-
./mvnw spring-boot:run
46+
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev
4747
if [ $? -ne 0 ]; then
4848
echo "Failed to start backend"
4949
exit $?

0 commit comments

Comments
 (0)