-
Notifications
You must be signed in to change notification settings - Fork 702
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
1 parent
fb29898
commit 83294cb
Showing
7 changed files
with
298 additions
and
8 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ore/src/main/java/dev/langchain4j/model/chat/observability/ChatLanguageModelListener.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 dev.langchain4j.model.chat.observability; | ||
|
||
import dev.langchain4j.Experimental; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
// TODO name | ||
// TODO package | ||
@Experimental | ||
public interface ChatLanguageModelListener { | ||
|
||
|
||
/** | ||
* TODO | ||
* | ||
* @param request | ||
*/ | ||
// TODO names | ||
@Experimental | ||
default void onRequest(String id, ChatLanguageModelRequest request) { | ||
|
||
} | ||
|
||
/** | ||
* TODO | ||
* | ||
* @param response | ||
*/ | ||
// TODO names | ||
// TODO accept Response<AiMessage> ? | ||
@Experimental | ||
default void onResponse(String id, ChatLanguageModelResponse response) { | ||
|
||
} | ||
|
||
// TODO onError? | ||
} |
34 changes: 34 additions & 0 deletions
34
...core/src/main/java/dev/langchain4j/model/chat/observability/ChatLanguageModelRequest.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,34 @@ | ||
package dev.langchain4j.model.chat.observability; | ||
|
||
import dev.langchain4j.Experimental; | ||
import dev.langchain4j.agent.tool.ToolSpecification; | ||
import dev.langchain4j.data.message.ChatMessage; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
@Builder | ||
@Experimental | ||
public class ChatLanguageModelRequest { | ||
|
||
private final String system; // gen_ai.system | ||
private final String modelName; // gen_ai.request.model | ||
|
||
// TODO group into "Parameters" POJO and re-use in ChatLanguageModel.generate()? | ||
private final Double temperature; // gen_ai.request.temperature | ||
private final Double topP; // gen_ai.request.top_p | ||
private final Integer maxTokens; // gen_ai.request.max_tokens | ||
|
||
// event | ||
private final List<ChatMessage> messages; // gen_ai.prompt // TODO copy | ||
private final List<ToolSpecification> toolSpecifications; // TODO copy | ||
|
||
public List<ChatMessage> messages() { | ||
return messages; | ||
} | ||
|
||
// TODO other getters | ||
} |
29 changes: 29 additions & 0 deletions
29
...ore/src/main/java/dev/langchain4j/model/chat/observability/ChatLanguageModelResponse.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,29 @@ | ||
package dev.langchain4j.model.chat.observability; | ||
|
||
import dev.langchain4j.Experimental; | ||
import dev.langchain4j.data.message.AiMessage; | ||
import dev.langchain4j.model.output.FinishReason; | ||
import dev.langchain4j.model.output.TokenUsage; | ||
import lombok.Builder; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
@Builder | ||
@Experimental | ||
public class ChatLanguageModelResponse { | ||
|
||
private final String id; // gen_ai.response.id | ||
private final String modelName; // gen_ai.response.model | ||
private final TokenUsage tokenUsage; // gen_ai.usage.completion_tokens + gen_ai.usage.prompt_tokens | ||
private final FinishReason finishReason; // gen_ai.response.finish_reasons | ||
|
||
// event | ||
private final AiMessage aiMessage; // gen_ai.completion | ||
|
||
public AiMessage aiMessage() { | ||
return aiMessage; | ||
} | ||
|
||
// TODO other getters | ||
} |
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
Oops, something went wrong.