Skip to content

Commit ef534b5

Browse files
committed
Apply formatting rules
1 parent a544c39 commit ef534b5

File tree

50 files changed

+2793
-2552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2793
-2552
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright (c) Microsoft. All rights reserved.
12
package com.microsoft.openai.samples.rag;
23

34
import org.slf4j.Logger;
@@ -11,7 +12,9 @@ public class Application {
1112
private static final Logger LOG = LoggerFactory.getLogger(Application.class);
1213

1314
public static void main(String[] args) {
14-
LOG.info("Application profile from system property is [{}]", System.getProperty("spring.profiles.active"));
15+
LOG.info(
16+
"Application profile from system property is [{}]",
17+
System.getProperty("spring.profiles.active"));
1518
new SpringApplication(Application.class).run(args);
1619
}
1720
}
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
package com.microsoft.openai.samples.rag.approaches;
2-
3-
public class ContentSource {
4-
5-
private String sourceName;
6-
private String sourceContent;
7-
private final boolean noNewLine;
8-
9-
public ContentSource(String sourceName, String sourceContent, Boolean noNewLine) {
10-
this.noNewLine = noNewLine;
11-
this.sourceName = sourceName;
12-
buildContent(sourceContent);
13-
}
14-
15-
public ContentSource(String sourceName, String sourceContent) {
16-
this(sourceName, sourceContent, true);
17-
}
18-
19-
public String getSourceName() {
20-
return sourceName;
21-
}
22-
23-
public void setSourceName(String sourceName) {
24-
this.sourceName = sourceName;
25-
}
26-
27-
public String getSourceContent() {
28-
return sourceContent;
29-
}
30-
31-
public void setSourceContent(String sourceContent) {
32-
this.sourceContent = sourceContent;
33-
}
34-
35-
public boolean isNoNewLine() {
36-
return noNewLine;
37-
}
38-
39-
private void buildContent(String sourceContent) {
40-
if (this.noNewLine) {
41-
this.sourceContent = sourceContent.replace("\n", "");
42-
}
43-
}
44-
45-
}
1+
// Copyright (c) Microsoft. All rights reserved.
2+
package com.microsoft.openai.samples.rag.approaches;
3+
4+
public class ContentSource {
5+
6+
private String sourceName;
7+
private String sourceContent;
8+
private final boolean noNewLine;
9+
10+
public ContentSource(String sourceName, String sourceContent, Boolean noNewLine) {
11+
this.noNewLine = noNewLine;
12+
this.sourceName = sourceName;
13+
buildContent(sourceContent);
14+
}
15+
16+
public ContentSource(String sourceName, String sourceContent) {
17+
this(sourceName, sourceContent, true);
18+
}
19+
20+
public String getSourceName() {
21+
return sourceName;
22+
}
23+
24+
public void setSourceName(String sourceName) {
25+
this.sourceName = sourceName;
26+
}
27+
28+
public String getSourceContent() {
29+
return sourceContent;
30+
}
31+
32+
public void setSourceContent(String sourceContent) {
33+
this.sourceContent = sourceContent;
34+
}
35+
36+
public boolean isNoNewLine() {
37+
return noNewLine;
38+
}
39+
40+
private void buildContent(String sourceContent) {
41+
if (this.noNewLine) {
42+
this.sourceContent = sourceContent.replace("\n", "");
43+
}
44+
}
45+
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package com.microsoft.openai.samples.rag.approaches;
2-
3-
public interface PromptTemplate {
4-
5-
String getPrompt();
6-
7-
void setVariables();
8-
9-
}
1+
// Copyright (c) Microsoft. All rights reserved.
2+
package com.microsoft.openai.samples.rag.approaches;
3+
4+
public interface PromptTemplate {
5+
6+
String getPrompt();
7+
8+
void setVariables();
9+
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
package com.microsoft.openai.samples.rag.approaches;
2-
3-
import com.microsoft.openai.samples.rag.common.ChatGPTConversation;
4-
import reactor.core.publisher.Flux;
5-
6-
import java.io.OutputStream;
7-
8-
public interface RAGApproach<I, O> {
9-
10-
O run(I questionOrConversation, RAGOptions options);
11-
void runStreaming(I questionOrConversation, RAGOptions options, OutputStream outputStream);
12-
}
1+
// Copyright (c) Microsoft. All rights reserved.
2+
package com.microsoft.openai.samples.rag.approaches;
3+
4+
import java.io.OutputStream;
5+
6+
public interface RAGApproach<I, O> {
7+
8+
O run(I questionOrConversation, RAGOptions options);
9+
10+
void runStreaming(I questionOrConversation, RAGOptions options, OutputStream outputStream);
11+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
// Copyright (c) Microsoft. All rights reserved.
12
package com.microsoft.openai.samples.rag.approaches;
23

34
public interface RAGApproachFactory<I, O> {
45

56
RAGApproach<I, O> createApproach(String approachName, RAGType ragType, RAGOptions options);
6-
77
}

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
// Copyright (c) Microsoft. All rights reserved.
12
package com.microsoft.openai.samples.rag.approaches;
23

34
import com.microsoft.openai.samples.rag.ask.approaches.PlainJavaAskApproach;
45
import com.microsoft.openai.samples.rag.ask.approaches.semantickernel.JavaSemanticKernelChainsApproach;
5-
import com.microsoft.openai.samples.rag.ask.approaches.semantickernel.JavaSemanticKernelWithMemoryApproach;
66
import com.microsoft.openai.samples.rag.ask.approaches.semantickernel.JavaSemanticKernelPlannerApproach;
7+
import com.microsoft.openai.samples.rag.ask.approaches.semantickernel.JavaSemanticKernelWithMemoryApproach;
78
import com.microsoft.openai.samples.rag.chat.approaches.PlainJavaChatApproach;
89
import org.springframework.context.ApplicationContext;
910
import org.springframework.context.ApplicationContextAware;
1011
import org.springframework.stereotype.Component;
1112

1213
@Component
13-
public class RAGApproachFactorySpringBootImpl implements RAGApproachFactory, ApplicationContextAware {
14+
public class RAGApproachFactorySpringBootImpl
15+
implements RAGApproachFactory, ApplicationContextAware {
1416

1517
private static final String JAVA_OPENAI_SDK = "jos";
1618
private static final String JAVA_SEMANTIC_KERNEL = "jsk";
@@ -35,18 +37,23 @@ public RAGApproach createApproach(String approachName, RAGType ragType, RAGOptio
3537
return applicationContext.getBean(PlainJavaAskApproach.class);
3638
else if (JAVA_SEMANTIC_KERNEL.equals(approachName))
3739
return applicationContext.getBean(JavaSemanticKernelWithMemoryApproach.class);
38-
else if (JAVA_SEMANTIC_KERNEL_PLANNER.equals(approachName) && ragOptions.getSemantickKernelMode() != null && ragOptions.getSemantickKernelMode() == SemanticKernelMode.planner)
39-
return applicationContext.getBean(JavaSemanticKernelPlannerApproach.class);
40-
else if(JAVA_SEMANTIC_KERNEL_PLANNER.equals(approachName) && ragOptions != null && ragOptions.getSemantickKernelMode() != null && ragOptions.getSemantickKernelMode() == SemanticKernelMode.chains)
41-
return applicationContext.getBean(JavaSemanticKernelChainsApproach.class);
42-
40+
else if (JAVA_SEMANTIC_KERNEL_PLANNER.equals(approachName)
41+
&& ragOptions.getSemantickKernelMode() != null
42+
&& ragOptions.getSemantickKernelMode() == SemanticKernelMode.planner)
43+
return applicationContext.getBean(JavaSemanticKernelPlannerApproach.class);
44+
else if (JAVA_SEMANTIC_KERNEL_PLANNER.equals(approachName)
45+
&& ragOptions != null
46+
&& ragOptions.getSemantickKernelMode() != null
47+
&& ragOptions.getSemantickKernelMode() == SemanticKernelMode.chains)
48+
return applicationContext.getBean(JavaSemanticKernelChainsApproach.class);
4349
}
44-
//if this point is reached then the combination of approach and rag type is not supported
45-
throw new IllegalArgumentException("Invalid combination for approach[%s] and rag type[%s]: ".formatted(approachName, ragType));
50+
// if this point is reached then the combination of approach and rag type is not supported
51+
throw new IllegalArgumentException(
52+
"Invalid combination for approach[%s] and rag type[%s]: "
53+
.formatted(approachName, ragType));
4654
}
4755

4856
public void setApplicationContext(ApplicationContext applicationContext) {
4957
this.applicationContext = applicationContext;
5058
}
51-
5259
}

0 commit comments

Comments
 (0)