Package com.tnsai.session.extraction
Class LLMKnowledgeExtractor
java.lang.Object
com.tnsai.session.extraction.LLMKnowledgeExtractor
- All Implemented Interfaces:
KnowledgeExtractor
LLM-based knowledge extractor.
Uses an LLM to analyze session conversations and extract reusable knowledge like solutions, patterns, and insights.
Usage
LLMClient llm = new OpenAIClient("gpt-4o-mini", apiKey);
KnowledgeExtractor extractor = new LLMKnowledgeExtractor(llm);
List<ExtractedKnowledge> knowledge = extractor.extract(session);
// Filter high-confidence results
knowledge.stream()
.filter(k -> k.isHighConfidence())
.forEach(k -> System.out.println(k.type() + ": " + k.summary()));
- Author:
- TnsAI Team
-
Constructor Summary
ConstructorsConstructorDescriptionLLMKnowledgeExtractor(com.tnsai.llm.LLMClient llmClient) Creates an extractor with default settings.LLMKnowledgeExtractor(com.tnsai.llm.LLMClient llmClient, double minConfidence) Creates an extractor with custom confidence threshold. -
Method Summary
Modifier and TypeMethodDescriptionextract(AgentSession session, Set<ExtractionType> types) Extracts specific types of knowledge from a session.doubleGets the minimum confidence threshold for extraction.withMinConfidence(double minConfidence) Creates a new extractor with a different confidence threshold.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tnsai.session.extraction.KnowledgeExtractor
extract, extractAll, extractAll
-
Constructor Details
-
LLMKnowledgeExtractor
public LLMKnowledgeExtractor(com.tnsai.llm.LLMClient llmClient) Creates an extractor with default settings.- Parameters:
llmClient- the LLM client to use for extraction
-
LLMKnowledgeExtractor
public LLMKnowledgeExtractor(com.tnsai.llm.LLMClient llmClient, double minConfidence) Creates an extractor with custom confidence threshold.- Parameters:
llmClient- the LLM client to useminConfidence- minimum confidence threshold (0.0 to 1.0)
-
-
Method Details
-
extract
Description copied from interface:KnowledgeExtractorExtracts specific types of knowledge from a session.- Specified by:
extractin interfaceKnowledgeExtractor- Parameters:
session- the session to extract fromtypes- the types of knowledge to extract- Returns:
- list of extracted knowledge items
-
getMinConfidence
public double getMinConfidence()Description copied from interface:KnowledgeExtractorGets the minimum confidence threshold for extraction. Items below this threshold will not be returned.- Specified by:
getMinConfidencein interfaceKnowledgeExtractor- Returns:
- minimum confidence (0.0 to 1.0)
-
withMinConfidence
Description copied from interface:KnowledgeExtractorCreates a new extractor with a different confidence threshold.- Specified by:
withMinConfidencein interfaceKnowledgeExtractor- Parameters:
minConfidence- the minimum confidence threshold- Returns:
- a new extractor with the specified threshold
-