kevinhug commited on
Commit
2379f57
·
1 Parent(s): 4664994

human-in-the-loop

Browse files
Files changed (3) hide show
  1. app.py +12 -10
  2. entity.py +4 -0
  3. human.py +5 -5
app.py CHANGED
@@ -126,7 +126,7 @@ Companies in competitive industries are constantly under pressure to innovate—
126
  - Lack of insight into customer feedback on competitor features.
127
  - Difficulty in predicting how new features will be received in the market.
128
 
129
- ### 🧩 The real question:
130
  How can your product stay ahead of the competition without a clear understanding of what features your competitors are developing, and how they’re performing with customers?
131
 
132
  ### 🎯 The customer need:
@@ -148,7 +148,7 @@ By leveraging AI, market intelligence, and competitive analysis tools, you can t
148
 
149
  With the right competitive research, you don’t just react to the market—you anticipate it.
150
  """)
151
- with gr.Tab("Graphrag Marketing Plan"):
152
  gr.Markdown("""
153
  Objective: Develop a Targeted Marketing Plan Aligned with Customer Personas
154
  =======================
@@ -212,7 +212,7 @@ Quickly generates tailored campaigns, reducing go-to-market time from weeks to h
212
  Uses customer data and behavior to craft messages that resonate with specific segments.
213
  """)
214
 
215
- with gr.Tab("Personalized Knowledge Graph"):
216
  gr.Markdown("""
217
  Objective: Transform Personal Pain Points into Actionable Insights with a Dynamic Knowledge Graph Framework
218
  =====================================
@@ -350,7 +350,7 @@ Allows downstream tasks (like sentiment analysis or topic modeling) to focus on
350
  """)
351
 
352
 
353
- with gr.Tab("Classify & Guardrail"):
354
  gr.Markdown("""
355
  Objective: Streamline Customer Insights: Auto-Classify Feedback for Product Optimization
356
  ================================================
@@ -393,10 +393,12 @@ Proactively flags 5+ fraud types (identity theft, money laundering) with 40% few
393
  Auto-classifies documents for FINRA/SEC audits (e.g., Morgan Stanley uses NLP to categorize 3M+ annual communications into 50+ compliance buckets).
394
  """)
395
 
396
- with gr.Tab("Resolution for Call Center"):
397
  gr.Markdown("""
398
  Objective: Proactive Entity Mapping: Clarifying Critical Elements in Complex Call Analysis for Strategic Insight
399
  ================================================
 
 
400
  """)
401
  in_verbatim = gr.Textbox(label="Content")
402
  out_product = gr.Textbox(label="Entity Resolution")
@@ -466,18 +468,18 @@ Example of Call Resolution
466
 
467
  ![Resolution for Clear Picture about Customer Issue..](file=./entity.png)
468
 
469
- #### Resolution for Clear Picture about Customer Issue
470
  https://i.postimg.cc/J4qsDYtZ/entity.png
471
 
472
  Companies like RBC, Comcast, or BMO often face a recurring challenge: long, complex customer service calls filled with vague product references, overlapping account details, and unstructured issue descriptions. This makes it difficult for support teams and analytics engines to extract clear insights or resolve recurring pain points across accounts and products.
473
 
474
- How can teams automatically stitch together fragmented mentions of the same customer, product, or issue—across call transcripts, CRM records, and support tickets—to form a unified view of the actual problem?
475
 
476
  That's where Entity Resolution comes in. By linking related entities hidden across data silos and messy text (like "my internet box" = "ARRIS TG1682G" or "John Smith, J. Smith, and [email protected]"), teams gain a clearer, contextual understanding of customer frustration in real-time.
477
 
478
  For example, Comcast reduced repeat service calls by 17% after deploying entity resolution models on long call transcripts—turning messy feedback into actionable product insights and faster resolutions.
479
 
480
- The result? Less agent time lost, higher customer satisfaction, and data pipelines that actually speak human.
481
  """)
482
  with gr.Tab("Human Feedback Content"):
483
  gr.Markdown("""
@@ -496,7 +498,7 @@ The result? Less agent time lost, higher customer satisfaction, and data pipelin
496
  ],
497
  [in_verbatim, in_campaign]
498
  )
499
- btn_recommend = gr.Button("Resolve")
500
  btn_recommend.click(fn=email, inputs=[in_verbatim, in_campaign, out_product], outputs=out_product)
501
 
502
  h_feedback = gr.Radio(['approved', 'rejected'], label="Human Feedback", info="Which campaign you want to approve?")
@@ -515,7 +517,7 @@ The result? Less agent time lost, higher customer satisfaction, and data pipelin
515
 
516
  - 52% faster ROI through AI-driven personalization scaling
517
 
518
- #### Ask: Ready to turn customer frustrations into loyalty drivers with content that feels personally crafted?"
519
 
520
  This approach aligns with best-in-class use cases where feedback-driven personalization drives measurable business growth
521
  """)
 
126
  - Lack of insight into customer feedback on competitor features.
127
  - Difficulty in predicting how new features will be received in the market.
128
 
129
+ ## 🧩 The real question:
130
  How can your product stay ahead of the competition without a clear understanding of what features your competitors are developing, and how they’re performing with customers?
131
 
132
  ### 🎯 The customer need:
 
148
 
149
  With the right competitive research, you don’t just react to the market—you anticipate it.
150
  """)
151
+ with gr.Tab("Graphrag Marketing"):
152
  gr.Markdown("""
153
  Objective: Develop a Targeted Marketing Plan Aligned with Customer Personas
154
  =======================
 
212
  Uses customer data and behavior to craft messages that resonate with specific segments.
213
  """)
214
 
215
+ with gr.Tab("Personalized KG"):
216
  gr.Markdown("""
217
  Objective: Transform Personal Pain Points into Actionable Insights with a Dynamic Knowledge Graph Framework
218
  =====================================
 
350
  """)
351
 
352
 
353
+ with gr.Tab("Classify"):
354
  gr.Markdown("""
355
  Objective: Streamline Customer Insights: Auto-Classify Feedback for Product Optimization
356
  ================================================
 
393
  Auto-classifies documents for FINRA/SEC audits (e.g., Morgan Stanley uses NLP to categorize 3M+ annual communications into 50+ compliance buckets).
394
  """)
395
 
396
+ with gr.Tab("Call Resolution"):
397
  gr.Markdown("""
398
  Objective: Proactive Entity Mapping: Clarifying Critical Elements in Complex Call Analysis for Strategic Insight
399
  ================================================
400
+ - Graph relationship between entity
401
+ - summary of the interaction
402
  """)
403
  in_verbatim = gr.Textbox(label="Content")
404
  out_product = gr.Textbox(label="Entity Resolution")
 
468
 
469
  ![Resolution for Clear Picture about Customer Issue..](file=./entity.png)
470
 
471
+ Resolution for Clear Picture about Customer Issue
472
  https://i.postimg.cc/J4qsDYtZ/entity.png
473
 
474
  Companies like RBC, Comcast, or BMO often face a recurring challenge: long, complex customer service calls filled with vague product references, overlapping account details, and unstructured issue descriptions. This makes it difficult for support teams and analytics engines to extract clear insights or resolve recurring pain points across accounts and products.
475
 
476
+ #### How can teams automatically stitch together fragmented mentions of the same customer, product, or issue—across call transcripts, CRM records, and support tickets—to form a unified view of the actual problem?
477
 
478
  That's where Entity Resolution comes in. By linking related entities hidden across data silos and messy text (like "my internet box" = "ARRIS TG1682G" or "John Smith, J. Smith, and [email protected]"), teams gain a clearer, contextual understanding of customer frustration in real-time.
479
 
480
  For example, Comcast reduced repeat service calls by 17% after deploying entity resolution models on long call transcripts—turning messy feedback into actionable product insights and faster resolutions.
481
 
482
+ ### The result? Less agent time lost, higher customer satisfaction, and data pipelines that actually speak human.
483
  """)
484
  with gr.Tab("Human Feedback Content"):
485
  gr.Markdown("""
 
498
  ],
499
  [in_verbatim, in_campaign]
500
  )
501
+ btn_recommend = gr.Button("Personalized Email")
502
  btn_recommend.click(fn=email, inputs=[in_verbatim, in_campaign, out_product], outputs=out_product)
503
 
504
  h_feedback = gr.Radio(['approved', 'rejected'], label="Human Feedback", info="Which campaign you want to approve?")
 
517
 
518
  - 52% faster ROI through AI-driven personalization scaling
519
 
520
+ ### Ready to turn customer frustrations into loyalty drivers with content that feels personally crafted?
521
 
522
  This approach aligns with best-in-class use cases where feedback-driven personalization drives measurable business growth
523
  """)
entity.py CHANGED
@@ -51,6 +51,10 @@ class Entity(BaseModel):
51
 
52
 
53
  class DocumentExtraction(BaseModel):
 
 
 
 
54
  entities: List[Entity] = Field(
55
  ...,
56
  description="Body of the answer, each fact should be a separate object with a body and a list of sources such as Organization, Agreement Date, Asset...etc",
 
51
 
52
 
53
  class DocumentExtraction(BaseModel):
54
+ summary: str= Field(
55
+ ...,
56
+ description="concise summary of the interaction for customer issue and representative solution",
57
+ )
58
  entities: List[Entity] = Field(
59
  ...,
60
  description="Body of the answer, each fact should be a separate object with a body and a list of sources such as Organization, Agreement Date, Asset...etc",
human.py CHANGED
@@ -20,8 +20,8 @@ llm_with_tools = llm #.bind_tools(tools)
20
  from langchain_groq import ChatGroq
21
 
22
  llm = ChatGroq(
23
- model="llama-3.1-8b-instant",
24
- temperature=0,
25
  max_tokens=None,
26
  timeout=None,
27
  max_retries=2,
@@ -64,7 +64,7 @@ graph_builder = StateGraph(State)
64
 
65
 
66
  def write_email(state: State):
67
- prompt = f"""Write an promotional personalized email for this persona:
68
  {state["persona"]}
69
  """
70
  email = llm_with_tools.invoke(prompt)
@@ -115,14 +115,14 @@ def email(persona, campaign, history):
115
  thread_config = {"configurable": {"thread_id": campaign}}
116
  for event in graph.stream({"persona": persona}, config=thread_config):
117
  for value in event.values():
118
- return r"\nAssistant: ", value, r"\nValue: ", graph.get_state(thread_config).values
119
 
120
 
121
  def feedback(deliver, campaign, history):
122
  thread_config = {"configurable": {"thread_id": campaign}}
123
  for event in graph.stream(Command(resume=deliver), config=thread_config):
124
  for value in event.values():
125
- return r"\nAssistant: ", value, r"\nValue: ", graph.get_state(thread_config).values
126
 
127
 
128
  '''
 
20
  from langchain_groq import ChatGroq
21
 
22
  llm = ChatGroq(
23
+ model="gemma2-9b-it", #"llama-3.1-8b-instant",
24
+ temperature=0.4,
25
  max_tokens=None,
26
  timeout=None,
27
  max_retries=2,
 
64
 
65
 
66
  def write_email(state: State):
67
+ prompt = f"""Write an promotional personalized email for this persona and offer financial education and setup a meeting for financial advisor, Only the email nothing else:
68
  {state["persona"]}
69
  """
70
  email = llm_with_tools.invoke(prompt)
 
115
  thread_config = {"configurable": {"thread_id": campaign}}
116
  for event in graph.stream({"persona": persona}, config=thread_config):
117
  for value in event.values():
118
+ return r"Assistant: ", value, r"Value: ", graph.get_state(thread_config).values
119
 
120
 
121
  def feedback(deliver, campaign, history):
122
  thread_config = {"configurable": {"thread_id": campaign}}
123
  for event in graph.stream(Command(resume=deliver), config=thread_config):
124
  for value in event.values():
125
+ return r"Assistant: ", value, r"Value: ", graph.get_state(thread_config).values
126
 
127
 
128
  '''