EnrichmentWithOllama
Enrichment class using Ollama model based on LangChain Enrichment class.
EnrichmentWithOllama
Bases: Enrichments
Enrichment class using Ollama model based on the Enrichment abstract class.
Source code in aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py
17 18 19 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
__init__(model_name, prompt_enrichment, temperature, streaming)
Initialize the EnrichmentWithOllama class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the Ollama model to be used. |
required |
prompt_enrichment
|
str
|
The prompt enrichment template. |
required |
temperature
|
float
|
The temperature for the Ollama model. |
required |
streaming
|
bool
|
The streaming flag for the Ollama model. |
required |
Source code in aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
__setup(model_name)
Check if the Ollama model is available and run the Ollama server if needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the Ollama model to be used. |
required |
Source code in aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
enrich_documents(texts)
Enrich a list of input texts with additional textual features using OLLAMA model. Important: Make sure the input is a list of texts based on the defined prompt template with 'input' as the variable name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texts
|
List[str]
|
The list of texts to be enriched. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
The list of enriched texts. |
Source code in aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
enrich_documents_with_rag(texts, docs)
Enrich a list of input texts with additional textual features using OLLAMA model with RAG. As of now, we don't have a RAG model to test this method yet. Thus, we will just call the enrich_documents method instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texts
|
The list of texts to be enriched. |
required | |
docs
|
The list of reference documents to enrich the input texts. |
required |
Returns:
Type | Description |
---|---|
The list of enriched texts |
Source code in aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|