Skip to content

Commit

Permalink
Docu: ai services
Browse files Browse the repository at this point in the history
  • Loading branch information
langchain4j committed Feb 9, 2024
1 parent c1462c0 commit 5d0ad94
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/docs/tutorials/5-ai-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ sidebar_position: 6

So far, we have been covering low-level components like `ChatLanguageModel`, `ChatMessage`, `ChatMemory`, etc.
Working at this level is very flexible and gives you total freedom, but it also forces you to write a lot of boilerplate code.
Since LLM-powered applications usually require not just a single component, but multiple components working together
(e.g., prompt templates, chat memory, LLMs, output parsing, RAG components: embedding models and stores),
orchestrating them all becomes even more cumbersome.
Since LLM-powered applications usually require not just a single component but multiple components working together
(e.g., prompt templates, chat memory, LLMs, output parsers, RAG components: embedding models and stores)
and often involve multiple interactions, orchestrating them all becomes even more cumbersome.

We want you to focus on business logic, not on low-level implementation details.
Thus, there are currently two high-level concepts in LangChain4j that can help with that: AI Services and Chains.
Expand Down Expand Up @@ -96,9 +96,9 @@ interface Bro {
String chat(String userMessage);
}

Bro bro = AiServices.create(Bro.class, model);
Bro bro = AiServices.create(Bro.class, model);

String answer = bro.chat("Hello"); // Hey! What's up?
String answer = bro.chat("Hello"); // Hey! What's up?
```
In this example, we have added the `@SystemMessage` annotation with a prompt we want to use.
This will be converted into a `SystemMessage` behind the scenes and sent to the LLM along with the `UserMessage`.
Expand All @@ -115,9 +115,9 @@ interface Bro {
String chat(String userMessage);
}

Bro bro = AiServices.create(Bro.class, model);
Bro bro = AiServices.create(Bro.class, model);

String answer = bro.chat("Hello"); // Hey! What's shakin'?
String answer = bro.chat("Hello"); // Hey! What's shakin'?
```
We have replaced the `@SystemMessage` annotation with `@UserMessage`
and specified a prompt template with the variable `it` to refer to the only method argument.
Expand Down

0 comments on commit 5d0ad94

Please sign in to comment.