heymenn commited on
Commit
a81e04e
·
verified ·
1 Parent(s): ead7603

Update kig_core/graph_operations.py

Browse files
Files changed (1) hide show
  1. kig_core/graph_operations.py +5 -5
kig_core/graph_operations.py CHANGED
@@ -10,7 +10,7 @@ from langchain_core.pydantic_v1 import Field, BaseModel as V1BaseModel # For gra
10
 
11
  from .config import settings
12
  from .graph_client import neo4j_client # Use the central client
13
- from .llm_interface import get_llm
14
  from .prompts import (
15
  CYPHER_GENERATION_PROMPT, CONCEPT_SELECTION_PROMPT,
16
  BINARY_GRADER_PROMPT, SCORE_GRADER_PROMPT
@@ -47,7 +47,7 @@ def generate_cypher_auto(question: str) -> str:
47
  | StrOutputParser()
48
  | extract_cypher
49
  )
50
- return chain.invoke(question)
51
 
52
  def generate_cypher_guided(question: str, plan_step: int) -> str:
53
  """Generates Cypher using the 'guided' method based on concepts."""
@@ -64,7 +64,7 @@ def generate_cypher_guided(question: str, plan_step: int) -> str:
64
  | concept_llm
65
  | StrOutputParser()
66
  )
67
- selected_concept = concept_chain.invoke({
68
  "question": question,
69
  "concepts": "\n".join(concepts)
70
  }).strip()
@@ -179,7 +179,7 @@ def evaluate_documents(
179
  formatted_doc = format_doc_for_llm(doc)
180
  if not formatted_doc.strip(): continue
181
  try:
182
- result = binary_grader.invoke({"question": query, "document": formatted_doc})
183
  logger.debug(f"Binary grader result for doc '{doc.get('title', 'N/A')}': {result}")
184
  if result and 'yes' in result.lower():
185
  valid_docs_with_scores.append((doc, 1.0)) # Score 1.0 for relevant
@@ -193,7 +193,7 @@ def evaluate_documents(
193
  formatted_doc = format_doc_for_llm(doc)
194
  if not formatted_doc.strip(): continue
195
  try:
196
- result: GradeDocumentsScore = score_grader.invoke({"query": query, "document": formatted_doc})
197
  logger.debug(f"Score grader result for doc '{doc.get('title', 'N/A')}': Score={result.score}, Rationale={result.rationale}")
198
  if result.score >= settings.eval_threshold:
199
  valid_docs_with_scores.append((doc, result.score))
 
10
 
11
  from .config import settings
12
  from .graph_client import neo4j_client # Use the central client
13
+ from .llm_interface import get_llm, invoke_llm
14
  from .prompts import (
15
  CYPHER_GENERATION_PROMPT, CONCEPT_SELECTION_PROMPT,
16
  BINARY_GRADER_PROMPT, SCORE_GRADER_PROMPT
 
47
  | StrOutputParser()
48
  | extract_cypher
49
  )
50
+ return llm_invoke(chain,question)
51
 
52
  def generate_cypher_guided(question: str, plan_step: int) -> str:
53
  """Generates Cypher using the 'guided' method based on concepts."""
 
64
  | concept_llm
65
  | StrOutputParser()
66
  )
67
+ selected_concept = llm_invoke(concept_chain,{
68
  "question": question,
69
  "concepts": "\n".join(concepts)
70
  }).strip()
 
179
  formatted_doc = format_doc_for_llm(doc)
180
  if not formatted_doc.strip(): continue
181
  try:
182
+ result = llm_invoke(binary_grader,{"question": query, "document": formatted_doc})
183
  logger.debug(f"Binary grader result for doc '{doc.get('title', 'N/A')}': {result}")
184
  if result and 'yes' in result.lower():
185
  valid_docs_with_scores.append((doc, 1.0)) # Score 1.0 for relevant
 
193
  formatted_doc = format_doc_for_llm(doc)
194
  if not formatted_doc.strip(): continue
195
  try:
196
+ result: GradeDocumentsScore = llm_invoke(score_grader,{"query": query, "document": formatted_doc})
197
  logger.debug(f"Score grader result for doc '{doc.get('title', 'N/A')}': Score={result.score}, Rationale={result.rationale}")
198
  if result.score >= settings.eval_threshold:
199
  valid_docs_with_scores.append((doc, result.score))