-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
143 additions
and
80 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
langchain4j/src/main/java/zin/rashidi/boot/langchain4j/history/Historian.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package zin.rashidi.boot.langchain4j.history; | ||
|
||
import dev.langchain4j.service.SystemMessage; | ||
import dev.langchain4j.service.UserMessage; | ||
import dev.langchain4j.service.V; | ||
|
||
/** | ||
* @author Rashidi Zin | ||
*/ | ||
interface Historian { | ||
|
||
@SystemMessage(""" | ||
You are a historian who is an expert for {{country}}. | ||
Given provided year is supported, you will provide historical events that occurred within the year. | ||
You will also include detail about the event. | ||
""") | ||
@UserMessage("{{year}}") | ||
History chat(@V("country") String country, @V("year") int year); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
langchain4j/src/main/java/zin/rashidi/boot/langchain4j/history/HistorianTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package zin.rashidi.boot.langchain4j.history; | ||
|
||
import dev.langchain4j.agent.tool.P; | ||
import dev.langchain4j.agent.tool.Tool; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.Assert; | ||
|
||
import java.time.LocalDate; | ||
import java.time.Year; | ||
|
||
/** | ||
* @author Rashidi Zin | ||
*/ | ||
@Component | ||
class HistorianTool { | ||
|
||
@Tool("Validate year is supported") | ||
public void assertYear(int year) { | ||
Assert.isTrue(year < 2021, "Year must be less than 2021"); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
langchain4j/src/main/java/zin/rashidi/boot/langchain4j/history/History.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package zin.rashidi.boot.langchain4j.history; | ||
|
||
/** | ||
* @author Rashidi Zin | ||
*/ | ||
class History { | ||
|
||
private final String country; | ||
private final int year; | ||
private String person; | ||
private String event; | ||
private String error; | ||
|
||
public History(String country, int year) { | ||
this.country = country; | ||
this.year = year; | ||
} | ||
|
||
public String country() { | ||
return country; | ||
} | ||
|
||
public int year() { | ||
return year; | ||
} | ||
|
||
public String person() { | ||
return person; | ||
} | ||
|
||
public History person(String person) { | ||
this.person = person; | ||
return this; | ||
} | ||
|
||
public String event() { | ||
return event; | ||
} | ||
|
||
public History event(String event) { | ||
this.event = event; | ||
return this; | ||
} | ||
|
||
public String error() { | ||
return error; | ||
} | ||
|
||
public History error(String error) { | ||
this.error = error; | ||
return this; | ||
} | ||
|
||
} |
14 changes: 0 additions & 14 deletions
14
langchain4j/src/main/java/zin/rashidi/boot/langchain4j/translate/Translate.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
langchain4j/src/main/java/zin/rashidi/boot/langchain4j/translate/TranslationService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters