Skip to content

Commit c37b57c

Browse files
committed
feat: integrate Ollama for LLM tasks to enable on-premises testing
- Updated docs_to_knowledge_graph example to use Ollama instead of OpenAI - Added alternative configuration comments for OpenAI usage - Enables end-to-end testing without requiring OpenAI API key - Supports the Neo4j vector index method implementation
1 parent 0da98f9 commit c37b57c

File tree

1 file changed

+16
-4
lines changed
  • examples/docs_to_knowledge_graph

1 file changed

+16
-4
lines changed

examples/docs_to_knowledge_graph/main.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ def docs_to_kg_flow(
8282
cocoindex.functions.ExtractByLlm(
8383
llm_spec=cocoindex.LlmSpec(
8484
# Supported LLM: https://cocoindex.io/docs/ai/llm
85-
api_type=cocoindex.LlmApiType.OPENAI,
86-
model="gpt-4o",
85+
api_type=cocoindex.LlmApiType.OLLAMA,
86+
model="llama3.2",
87+
address="http://localhost:11434",
8788
),
89+
# Alternative: Use OpenAI API model instead of Ollama
90+
# llm_spec=cocoindex.LlmSpec(
91+
# api_type=cocoindex.LlmApiType.OPENAI,
92+
# model="gpt-4o",
93+
# ),
8894
output_type=DocumentSummary,
8995
instruction="Please summarize the content of the document.",
9096
)
@@ -100,9 +106,15 @@ def docs_to_kg_flow(
100106
cocoindex.functions.ExtractByLlm(
101107
llm_spec=cocoindex.LlmSpec(
102108
# Supported LLM: https://cocoindex.io/docs/ai/llm
103-
api_type=cocoindex.LlmApiType.OPENAI,
104-
model="gpt-4o",
109+
api_type=cocoindex.LlmApiType.OLLAMA,
110+
model="llama3.2",
111+
address="http://localhost:11434",
105112
),
113+
# Alternative: Use OpenAI API model instead of Ollama
114+
# llm_spec=cocoindex.LlmSpec(
115+
# api_type=cocoindex.LlmApiType.OPENAI,
116+
# model="gpt-4o",
117+
# ),
106118
output_type=list[Relationship],
107119
instruction=(
108120
"Please extract relationships from CocoIndex documents. "

0 commit comments

Comments
 (0)