-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1280 from edeandrea/rewrite-tools
Rewrite auditing to use CDI events
- Loading branch information
Showing
21 changed files
with
375 additions
and
398 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
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
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
94 changes: 0 additions & 94 deletions
94
core/runtime/src/main/java/io/quarkiverse/langchain4j/audit/Audit.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
core/runtime/src/main/java/io/quarkiverse/langchain4j/audit/AuditService.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
core/runtime/src/main/java/io/quarkiverse/langchain4j/audit/AuditSourceInfo.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,38 @@ | ||
package io.quarkiverse.langchain4j.audit; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Contains information about the source of an audit event | ||
*/ | ||
public interface AuditSourceInfo { | ||
/** | ||
* The fully-qualified name of the interface where the llm interaction was initialized | ||
* | ||
* @see #methodName() | ||
*/ | ||
String interfaceName(); | ||
|
||
/** | ||
* The method name on {@link #interfaceName()} where the llm interaction was initiated | ||
* | ||
* @see #interfaceName() | ||
*/ | ||
String methodName(); | ||
|
||
/** | ||
* The position of the memory id parameter in {@link #methodParams()}, if one exists | ||
*/ | ||
Optional<Integer> memoryIDParamPosition(); | ||
|
||
/** | ||
* The parameters passed into the initial LLM call | ||
*/ | ||
Object[] methodParams(); | ||
|
||
/** | ||
* A unique identifier that identifies this entire interaction with the LLM | ||
*/ | ||
UUID interactionId(); | ||
} |
13 changes: 13 additions & 0 deletions
13
core/runtime/src/main/java/io/quarkiverse/langchain4j/audit/InitialMessagesCreatedEvent.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,13 @@ | ||
package io.quarkiverse.langchain4j.audit; | ||
|
||
import java.util.Optional; | ||
|
||
import dev.langchain4j.data.message.SystemMessage; | ||
import dev.langchain4j.data.message.UserMessage; | ||
|
||
/** | ||
* Invoked when the original user and system messages have been created | ||
*/ | ||
public record InitialMessagesCreatedEvent(AuditSourceInfo sourceInfo, Optional<SystemMessage> systemMessage, | ||
UserMessage userMessage) implements LLMInteractionEvent { | ||
} |
7 changes: 7 additions & 0 deletions
7
core/runtime/src/main/java/io/quarkiverse/langchain4j/audit/LLMInteractionCompleteEvent.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,7 @@ | ||
package io.quarkiverse.langchain4j.audit; | ||
|
||
/** | ||
* Invoked when the final result of the AiService method has been computed | ||
*/ | ||
public record LLMInteractionCompleteEvent(AuditSourceInfo sourceInfo, Object result) implements LLMInteractionEvent { | ||
} |
5 changes: 5 additions & 0 deletions
5
core/runtime/src/main/java/io/quarkiverse/langchain4j/audit/LLMInteractionEvent.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,5 @@ | ||
package io.quarkiverse.langchain4j.audit; | ||
|
||
public interface LLMInteractionEvent { | ||
AuditSourceInfo sourceInfo(); | ||
} |
7 changes: 7 additions & 0 deletions
7
core/runtime/src/main/java/io/quarkiverse/langchain4j/audit/LLMInteractionFailureEvent.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,7 @@ | ||
package io.quarkiverse.langchain4j.audit; | ||
|
||
/** | ||
* Invoked when there was an exception computing the result of the AiService method | ||
*/ | ||
public record LLMInteractionFailureEvent(AuditSourceInfo sourceInfo, Exception error) implements LLMInteractionEvent { | ||
} |
Oops, something went wrong.