avfranco commited on
Commit
162ed68
·
1 Parent(s): ba8e285

ea4all-gradio-agents-mcp-hackathon-tools-refactoring-apm

Browse files
ea4all/src/ea4all_apm/graph.py CHANGED
@@ -516,7 +516,7 @@ def decide_to_generate(state):
516
  return "generate"
517
 
518
  def grade_generation_v_documents_and_question(
519
- state:OverallState, config: RunnableConfig):
520
  """
521
  Determines whether the generation is grounded in the document and answers question.
522
 
@@ -560,13 +560,13 @@ def grade_generation_v_documents_and_question(
560
  grade = output["score"]
561
  if grade == "yes":
562
  print("---DECISION: GENERATION ADDRESSES QUESTION---")
563
- yield "useful"
564
  else:
565
  print("---DECISION: GENERATION DOES NOT ADDRESS QUESTION---")
566
- yield "not useful"
567
  else:
568
  print("---DECISION: GENERATION IS NOT GROUNDED IN DOCUMENTS, RE-TRY---")
569
- yield "not supported"
570
 
571
  async def apm_query_router(
572
  state: OverallState, config: RunnableConfig
 
516
  return "generate"
517
 
518
  def grade_generation_v_documents_and_question(
519
+ state:OverallState, config: RunnableConfig) -> str:
520
  """
521
  Determines whether the generation is grounded in the document and answers question.
522
 
 
560
  grade = output["score"]
561
  if grade == "yes":
562
  print("---DECISION: GENERATION ADDRESSES QUESTION---")
563
+ return "useful"
564
  else:
565
  print("---DECISION: GENERATION DOES NOT ADDRESS QUESTION---")
566
+ return "not useful"
567
  else:
568
  print("---DECISION: GENERATION IS NOT GROUNDED IN DOCUMENTS, RE-TRY---")
569
+ return "not supported"
570
 
571
  async def apm_query_router(
572
  state: OverallState, config: RunnableConfig
ea4all/src/ea4all_apm/state.py CHANGED
@@ -33,33 +33,28 @@ class InputState:
33
 
34
  @dataclass(kw_only=True)
35
  class OutputState:
36
- """Represents the output schema for the APM agent.
37
- """
38
-
39
- answer: str
 
40
  """Answer to user's Architecture IT Landscape question about ."""
41
 
42
  @dataclass(kw_only=True)
43
- class OverallState(InputState):
44
  """State of the APM graph / agent."""
45
 
46
  """
47
  safety_status: user question's safeguarding status, justification, rephrased question
48
  router: classification of the user's query
49
  source: RAG or websearch
50
- web_search: whether to add search
51
  retrieved: list of documents retrieved by the retriever
52
  rag: last RAG approach used
53
  chat_memory: user chat memory
54
- generation: should the agent generate a response
55
- documents: list of documents retrieved by the retriever
56
  """
57
  safety_status: Optional[Tuple[str, str, str]] = None
58
  router: Optional[Router] = None
59
  source: Optional[str] = None
60
  rag: Optional[str] = None
61
- web_search: Optional[str] = None
62
  chat_memory: Optional[str] = None
63
- generation: Optional[str] = None
64
  retrieved: Optional[List[str]] = None
65
- documents: Optional[List[str]] = None
 
33
 
34
  @dataclass(kw_only=True)
35
  class OutputState:
36
+ """Represents the output schema for the APM agent."""
37
+ question: str
38
+ documents: Optional[List[str]] = None
39
+ generation: Optional[str] = None
40
+ web_search: Optional[str] = None
41
  """Answer to user's Architecture IT Landscape question about ."""
42
 
43
  @dataclass(kw_only=True)
44
+ class OverallState(InputState, OutputState):
45
  """State of the APM graph / agent."""
46
 
47
  """
48
  safety_status: user question's safeguarding status, justification, rephrased question
49
  router: classification of the user's query
50
  source: RAG or websearch
 
51
  retrieved: list of documents retrieved by the retriever
52
  rag: last RAG approach used
53
  chat_memory: user chat memory
 
 
54
  """
55
  safety_status: Optional[Tuple[str, str, str]] = None
56
  router: Optional[Router] = None
57
  source: Optional[str] = None
58
  rag: Optional[str] = None
 
59
  chat_memory: Optional[str] = None
 
60
  retrieved: Optional[List[str]] = None