Generate Answer
Generate an answer for a question using retrieved chunks of documents.
_build_context_and_sources(retrieved_chunks)
Build the combined context string and set of paper_ids from retrieved chunks.
Source code in aiagents4pharma/talk2scholars/tools/pdf/utils/generate_answer.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
generate_answer(question, retrieved_chunks, llm_model, config)
Generate an answer for a question using retrieved chunks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
question
|
str
|
The question to answer |
required |
retrieved_chunks
|
List[Document]
|
List of relevant document chunks |
required |
llm_model
|
BaseChatModel
|
Language model for generating answers |
required |
config
|
Any
|
Configuration for answer generation |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: Dictionary with the answer and metadata |
Source code in aiagents4pharma/talk2scholars/tools/pdf/utils/generate_answer.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
load_hydra_config()
Load the configuration using Hydra and return the configuration for the Q&A tool.
Source code in aiagents4pharma/talk2scholars/tools/pdf/utils/generate_answer.py
48 49 50 51 52 53 54 55 56 57 58 59 |
|