-
Notifications
You must be signed in to change notification settings - Fork 1
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
29 changed files
with
402 additions
and
170 deletions.
There are no files selected for viewing
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,107 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>nexus-command</artifactId> | ||
<groupId>net.savantly</groupId> | ||
<version>3.0.0</version> | ||
</parent> | ||
|
||
<artifactId>agents-module</artifactId> | ||
<name>Nexus Command - Agents Module</name> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
<resource> | ||
<filtering>false</filtering> | ||
<directory>src/main/java</directory> | ||
<includes> | ||
<include>**</include> | ||
</includes> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>common-types-module</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>encryption-module</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>organizations-module</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>nexus-ai-module</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>nexus-audited-entity-module</artifactId> | ||
</dependency> | ||
|
||
<!-- Spring --> | ||
|
||
|
||
<!-- CAUSEWAY API --> | ||
|
||
<dependency> | ||
<groupId>org.apache.causeway.core</groupId> | ||
<artifactId>causeway-applib</artifactId> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.apache.causeway.valuetypes</groupId> | ||
<artifactId>causeway-valuetypes-markdown-applib</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.causeway.persistence</groupId> | ||
<artifactId>causeway-persistence-jpa-applib</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.causeway.testing</groupId> | ||
<artifactId>causeway-testing-fixtures-applib</artifactId> | ||
</dependency> | ||
|
||
|
||
<!-- IDE support (optional) --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-configuration-processor</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
|
||
<!-- TESTING --> | ||
|
||
<dependency> | ||
<groupId>org.apache.causeway.testing</groupId> | ||
<artifactId>causeway-testing-integtestsupport-applib</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
</project> |
68 changes: 68 additions & 0 deletions
68
module-agents/src/main/java/net/savantly/nexus/agents/AgentsModule.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,68 @@ | ||
package net.savantly.nexus.agents; | ||
|
||
import org.apache.causeway.persistence.jpa.applib.CausewayModulePersistenceJpaApplib; | ||
import org.apache.causeway.testing.fixtures.applib.fixturescripts.FixtureScript; | ||
import org.apache.causeway.testing.fixtures.applib.modules.ModuleWithFixtures; | ||
import org.apache.causeway.testing.fixtures.applib.teardown.jpa.TeardownFixtureJpaAbstract; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
|
||
import dev.langchain4j.service.AiServices; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.savantly.ai.languagetools.LanguageToolModel; | ||
import net.savantly.nexus.agents.dom.generator.PersonaGenerator; | ||
|
||
@Configuration | ||
@Import({ | ||
CausewayModulePersistenceJpaApplib.class, | ||
}) | ||
@ComponentScan | ||
@EnableJpaRepositories | ||
@Slf4j | ||
@EntityScan(basePackageClasses = { AgentsModule.class }) | ||
@RequiredArgsConstructor | ||
@DependsOn("aiConfig") | ||
public class AgentsModule implements ModuleWithFixtures { | ||
|
||
public static final String NAMESPACE = "nexus.agents"; | ||
public static final String SCHEMA = "agents"; | ||
|
||
@Override | ||
public FixtureScript getTeardownFixture() { | ||
return new TeardownFixtureJpaAbstract() { | ||
@Override | ||
protected void execute(ExecutionContext executionContext) { | ||
// deleteFrom(FranchiseLocation.class); | ||
} | ||
}; | ||
} | ||
|
||
@Bean | ||
@Primary | ||
@ConditionalOnProperty("langchain4j.open-ai.chat-model.api-key") | ||
public PersonaGenerator personaGenerator(LanguageToolModel model) { | ||
log.info("Creating persona generator with model: {}", model); | ||
return AiServices.builder(PersonaGenerator.class) | ||
.chatLanguageModel(model.asChatLanguageModel()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public PersonaGenerator defaultPersonaGenerator() { | ||
log.info("Creating default persona generator"); | ||
return new PersonaGenerator() { | ||
}; | ||
} | ||
|
||
|
||
} |
17 changes: 17 additions & 0 deletions
17
module-agents/src/main/java/net/savantly/nexus/agents/dom/generator/PersonaGenerator.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,17 @@ | ||
package net.savantly.nexus.agents.dom.generator; | ||
|
||
import dev.langchain4j.service.SystemMessage; | ||
import dev.langchain4j.service.UserMessage; | ||
import dev.langchain4j.service.V; | ||
import net.savantly.nexus.agents.dom.persona.PersonaDTO; | ||
|
||
public interface PersonaGenerator { | ||
|
||
@SystemMessage("Generate a persona based on the provided context. The first name should start with the letter {{firstNameLetter}}.") | ||
@UserMessage("Context: {{context}}") | ||
default PersonaDTO generatePersona(@V("context") String context, @V("firstNameLetter") String firstNameLetter){ | ||
return new PersonaDTO().setName("Generated Persona").setDescription(context); | ||
} | ||
|
||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...ersona/OrganizationPersonaRepository.java → ...ersona/OrganizationPersonaRepository.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
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
2 changes: 1 addition & 1 deletion
2
...izationPersona/Organization_personas.java → ...izationPersona/Organization_personas.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
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...exus/projects/dom/persona/PersonaDTO.java → .../nexus/agents/dom/persona/PersonaDTO.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
2 changes: 1 addition & 1 deletion
2
...ojects/dom/persona/PersonaRepository.java → ...agents/dom/persona/PersonaRepository.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
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
Oops, something went wrong.