relevance_extractor_agent
langroid/agent/special/relevance_extractor_agent.py
Agent to retrieve relevant segments from a body of text, that are relevant to a query.
RelevanceExtractorAgent(config)
¶
Bases: ChatAgent
Agent for extracting segments from text, that are relevant to a given query.
Source code in langroid/agent/special/relevance_extractor_agent.py
llm_response(message=None)
¶
Compose a prompt asking to extract relevant segments from a passage. Steps: - number the segments in the passage - compose prompt - send to LLM
Source code in langroid/agent/special/relevance_extractor_agent.py
llm_response_async(message=None)
async
¶
Compose a prompt asking to extract relevant segments from a passage.
Steps:
- number the segments in the passage
- compose prompt
- send to LLM
The LLM is expected to generate a structured msg according to the
SegmentExtractTool schema, i.e. it should contain a segment_list
field
whose value is a list of segment numbers or ranges, like "10,12,14-17".
Source code in langroid/agent/special/relevance_extractor_agent.py
extract_segments(msg)
¶
Method to handle a segmentExtractTool message from LLM
Source code in langroid/agent/special/relevance_extractor_agent.py
handle_message_fallback(msg)
¶
Handle case where LLM forgets to use SegmentExtractTool