Skip to content

Commit 4580d5f

Browse files
authored
Example/cleaning (#196)
* Remove 'old' folder - add example for Ollama LLM * Update examples' README * Explicitly set 'return_context' to prevent warnings in examples
1 parent ad6424a commit 4580d5f

File tree

8 files changed

+27
-96
lines changed

8 files changed

+27
-96
lines changed

examples/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ are listed in [the last section of this file](#customize).
6767
- [MistralAI](./customize/llms/mistalai_llm.py)
6868
- [Cohere](./customize/llms/cohere_llm.py)
6969
- [Anthropic (Claude)](./customize/llms/anthropic_llm.py)
70-
- [Ollama]()
70+
- [Ollama](./customize/llms/ollama_llm.py)
7171
- [Custom LLM](./customize/llms/custom_llm.py)
7272

7373

@@ -91,6 +91,7 @@ are listed in [the last section of this file](#customize).
9191

9292
- [End to end example with explicit components and text input](./customize/build_graph/pipeline/kg_builder_from_text.py)
9393
- [End to end example with explicit components and PDF input](./customize/build_graph/pipeline/kg_builder_from_pdf.py)
94+
- [Process multiple documents](./customize/build_graph/pipeline/kg_builder_two_documents_entity_resolution.py)
9495

9596
#### Components
9697

examples/customize/answer/custom_prompt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454

5555
rag = GraphRAG(retriever=retriever, llm=llm, prompt_template=template)
5656

57-
result = rag.search("Tell me more about Avatar movies")
57+
result = rag.search(
58+
"Tell me more about Avatar movies",
59+
return_context=True,
60+
)
5861
print(result.answer)
5962

6063
driver.close()

examples/customize/answer/langchain_compatiblity.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
llm=llm, # type: ignore[arg-type, unused-ignore]
4141
)
4242

43-
result = rag.search("Tell me more about Avatar movies")
43+
result = rag.search(
44+
"Tell me more about Avatar movies",
45+
return_context=False,
46+
)
4447
print(result.answer)
4548

4649
driver.close()

examples/customize/llms/ollama_llm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from neo4j_graphrag.llm import LLMResponse, OpenAILLM
2+
3+
# not used but needs to be provided
4+
api_key = "ollama"
5+
6+
llm = OpenAILLM(
7+
base_url="http://localhost:11434/v1",
8+
model_name="<model_name>",
9+
api_key=api_key,
10+
)
11+
res: LLMResponse = llm.invoke("What is the additive color model?")
12+
print(res.content)

examples/old/pipeline/__init__.py

Whitespace-only changes.

examples/old/pipeline/kg_builder_example.py

Lines changed: 0 additions & 92 deletions
This file was deleted.

examples/question_answering/graphrag.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ def formatter(record: neo4j.Record) -> RetrieverResultItem:
5252

5353
rag = GraphRAG(retriever=retriever, llm=llm)
5454

55-
result = rag.search("Tell me more about Avatar movies")
55+
result = rag.search(
56+
"Tell me more about Avatar movies",
57+
return_context=True,
58+
)
5659
print(result.answer)
60+
# print(result.retriever_result)
5761

5862
driver.close()

0 commit comments

Comments
 (0)