Gemini 2.5 Pro এবং CrewAI এর সাথে গ্রাহক সহায়তা বিশ্লেষণ

CrewAI হল স্বায়ত্তশাসিত AI এজেন্টদের অর্কেস্ট্রেট করার একটি কাঠামো যা জটিল লক্ষ্য অর্জনে সহযোগিতা করে। এটি আপনাকে ভূমিকা, লক্ষ্য এবং ব্যাকস্টোরি নির্দিষ্ট করে এজেন্টদের সংজ্ঞায়িত করতে দেয় এবং তারপরে তাদের জন্য কাজগুলি সংজ্ঞায়িত করতে দেয়।

এই উদাহরণটি দেখায় যে কীভাবে সমস্যাগুলি সনাক্ত করতে এবং জেমিনি 2.5 প্রো ব্যবহার করে প্রক্রিয়া উন্নতির প্রস্তাব করতে গ্রাহক সহায়তা ডেটা বিশ্লেষণের জন্য একটি মাল্টি-এজেন্ট সিস্টেম তৈরি করতে হয়, একটি চিফ অপারেটিং অফিসার (সিওও) দ্বারা পড়ার উদ্দেশ্যে একটি প্রতিবেদন তৈরি করে৷

গাইড আপনাকে দেখাবে কিভাবে এআই এজেন্টদের একটি "ক্রু" তৈরি করতে হয় যা নিম্নলিখিত কাজগুলি করতে পারে:

  1. গ্রাহক সহায়তা ডেটা আনুন এবং বিশ্লেষণ করুন (এই উদাহরণে অনুকরণ করা হয়েছে)।
  2. পৌনঃপুনিক সমস্যা এবং প্রক্রিয়ার বাধা চিহ্নিত করুন।
  3. কর্মযোগ্য উন্নতির পরামর্শ দিন।
  4. একটি COO-এর জন্য উপযুক্ত একটি সংক্ষিপ্ত প্রতিবেদনে ফলাফলগুলি সংকলন করুন।

আপনার একটি Gemini API কী প্রয়োজন। আপনার যদি ইতিমধ্যে একটি না থাকে তবে আপনি Google AI স্টুডিওতে একটি পেতে পারেন।

pip install "crewai[tools]"

GEMINI_API_KEY নামের একটি পরিবেশ পরিবর্তনশীল হিসাবে আপনার Gemini API কী সেট করুন, তারপর Gemini 2.5 Pro মডেল ব্যবহার করতে CrewAI কনফিগার করুন।

import os
from crewai import LLM

# Read your API key from the environment variable
gemini_api_key = os.getenv("GEMINI_API_KEY")

# Use Gemini 2.5 Pro Experimental model
gemini_llm = LLM(
    model='gemini/gemini-2.5-pro',
    api_key=gemini_api_key,
    temperature=0.0  # Lower temperature for more consistent results.
)

উপাদান সংজ্ঞায়িত করুন

CrewAI অ্যাপ্লিকেশনগুলি টুল , এজেন্ট , টাস্ক এবং ক্রু নিজেই ব্যবহার করে তৈরি করা হয়। এই প্রতিটি নিম্নলিখিত বিভাগে ব্যাখ্যা করা হয়েছে.

টুলস

সরঞ্জামগুলি এমন ক্ষমতা যা এজেন্টরা বাইরের বিশ্বের সাথে যোগাযোগ করতে বা নির্দিষ্ট ক্রিয়া সম্পাদন করতে ব্যবহার করতে পারে। এখানে, আপনি গ্রাহক সহায়তা ডেটা আনার অনুকরণ করার জন্য একটি স্থানধারক টুল সংজ্ঞায়িত করেন। একটি বাস্তব অ্যাপ্লিকেশনে, আপনি একটি ডাটাবেস, API বা ফাইল সিস্টেমের সাথে সংযুক্ত হবেন। টুলস সম্পর্কে আরও তথ্যের জন্য, CrewAI টুলস গাইড দেখুন।

from crewai.tools import BaseTool

# Placeholder tool for fetching customer support data
class CustomerSupportDataTool(BaseTool):
    name: str = "Customer Support Data Fetcher"
    description: str = (
      "Fetches recent customer support interactions, tickets, and feedback. "
      "Returns a summary string.")

    def _run(self, argument: str) -> str:
        # In a real scenario, this would query a database or API.
        # For this example, return simulated data.
        print(f"--- Fetching data for query: {argument} ---")
        return (
            """Recent Support Data Summary:
- 50 tickets related to 'login issues'. High resolution time (avg 48h).
- 30 tickets about 'billing discrepancies'. Mostly resolved within 12h.
- 20 tickets on 'feature requests'. Often closed without resolution.
- Frequent feedback mentions 'confusing user interface' for password reset.
- High volume of calls related to 'account verification process'.
- Sentiment analysis shows growing frustration with 'login issues' resolution time.
- Support agent notes indicate difficulty reproducing 'login issues'."""
        )

support_data_tool = CustomerSupportDataTool()

এজেন্ট

এজেন্ট হল আপনার ক্রুতে থাকা স্বতন্ত্র এআই কর্মী। প্রতিটি এজেন্টের একটি নির্দিষ্ট role , goal , backstory , অ্যাসাইন করা llm এবং ঐচ্ছিক tools রয়েছে। এজেন্ট সম্পর্কে আরও তথ্যের জন্য, CrewAI এজেন্ট গাইড দেখুন।

from crewai import Agent

# Agent 1: Data analyst
data_analyst = Agent(
    role='Customer Support Data Analyst',
    goal='Analyze customer support data to identify trends, recurring issues, and key pain points.',
    backstory=(
        """You are an expert data analyst specializing in customer support operations.
        Your strength lies in identifying patterns and quantifying problems from raw support data."""
    ),
    verbose=True,
    allow_delegation=False,  # This agent focuses on its specific task
    tools=[support_data_tool],  # Assign the data fetching tool
    llm=gemini_llm  # Use the configured Gemini LLM
)

# Agent 2: Process optimizer
process_optimizer = Agent(
    role='Process Optimization Specialist',
    goal='Identify bottlenecks and inefficiencies in current support processes based on the data analysis. Propose actionable improvements.',
    backstory=(
        """You are a specialist in optimizing business processes, particularly in customer support.
        You excel at pinpointing root causes of delays and inefficiencies and suggesting concrete solutions."""
    ),
    verbose=True,
    allow_delegation=False,
    # No tools needed, this agent relies on the context provided by data_analyst.
    llm=gemini_llm
)

# Agent 3: Report writer
report_writer = Agent(
    role='Executive Report Writer',
    goal='Compile the analysis and improvement suggestions into a concise, clear, and actionable report for the COO.',
    backstory=(
        """You are a skilled writer adept at creating executive summaries and reports.
        You focus on clarity, conciseness, and highlighting the most critical information and recommendations for senior leadership."""
    ),
    verbose=True,
    allow_delegation=False,
    llm=gemini_llm
)

কাজ

কার্যগুলি এজেন্টদের জন্য নির্দিষ্ট অ্যাসাইনমেন্ট সংজ্ঞায়িত করে। প্রতিটি টাস্কের একটি description আছে, expected_output এবং একটি agent বরাদ্দ করা হয়। কার্যগুলি ডিফল্টরূপে ক্রমানুসারে চালানো হয় এবং পূর্ববর্তী টাস্কের প্রসঙ্গ অন্তর্ভুক্ত করে। কাজ সম্পর্কে আরও তথ্যের জন্য, CrewAI টাস্ক গাইড দেখুন।

from crewai import Task

# Task 1: Analyze data
analysis_task = Task(
    description=(
        """Fetch and analyze the latest customer support interaction data (tickets, feedback, call logs)
        focusing on the last quarter. Identify the top 3-5 recurring issues, quantify their frequency
        and impact (e.g., resolution time, customer sentiment). Use the Customer Support Data Fetcher tool."""
    ),
    expected_output=(
        """A summary report detailing the key findings from the customer support data analysis, including:
- Top 3-5 recurring issues with frequency.
- Average resolution times for these issues.
- Key customer pain points mentioned in feedback.
- Any notable trends in sentiment or support agent observations."""
    ),
    agent=data_analyst  # Assign task to the data_analyst agent
)

# Task 2: Identify bottlenecks and suggest improvements
optimization_task = Task(
    description=(
        """Based on the data analysis report provided by the Data Analyst, identify the primary bottlenecks
        in the support processes contributing to the identified issues (especially the top recurring ones).
        Propose 2-3 concrete, actionable process improvements to address these bottlenecks.
        Consider potential impact and ease of implementation."""
    ),
    expected_output=(
        """A concise list identifying the main process bottlenecks (e.g., lack of documentation for agents,
        complex escalation path, UI issues) linked to the key problems.
A list of 2-3 specific, actionable recommendations for process improvement
(e.g., update agent knowledge base, simplify password reset UI, implement proactive monitoring)."""
    ),
    agent=process_optimizer  # Assign task to the process_optimizer agent
    # This task implicitly uses the output of analysis_task as context
)

# Task 3: Compile COO report
report_task = Task(
    description=(
        """Compile the findings from the Data Analyst and the recommendations from the Process Optimization Specialist
        into a single, concise executive report for the COO. The report should clearly state:
1. The most critical customer support issues identified (with brief data points).
2. The key process bottlenecks causing these issues.
3. The recommended process improvements.
Ensure the report is easy to understand, focuses on actionable insights, and is formatted professionally."""
    ),
    expected_output=(
        """A well-structured executive report (max 1 page) summarizing the critical support issues,
        underlying process bottlenecks, and clear, actionable recommendations for the COO.
        Use clear headings and bullet points."""
    ),
    agent=report_writer  # Assign task to the report_writer agent
)

ক্রু

Crew এজেন্ট এবং কাজগুলিকে একত্রিত করে, ওয়ার্কফ্লো প্রক্রিয়াকে সংজ্ঞায়িত করে (যেমন "অনুক্রমিক")।

from crewai import Crew, Process

# Define the crew with agents, tasks, and process
support_analysis_crew = Crew(
    agents=[data_analyst, process_optimizer, report_writer],
    tasks=[analysis_task, optimization_task, report_task],
    process=Process.sequential,  # Tasks will run sequentially in the order defined
    verbose=True
)

ক্রু চালান

অবশেষে, যেকোন প্রয়োজনীয় ইনপুট দিয়ে ক্রু এক্সিকিউশন শুরু করুন।

# Start the crew's work
print("--- Starting Customer Support Analysis Crew ---")
# The 'inputs' dictionary provides initial context if needed by the first task.
# In this case, the tool simulates data fetching regardless of the input.
result = support_analysis_crew.kickoff(inputs={'data_query': 'last quarter support data'})

print("--- Crew Execution Finished ---")
print("--- Final Report for COO ---")
print(result)

স্ক্রিপ্ট এখন চালানো হবে. Data Analyst টুলটি ব্যবহার করবে, Process Optimizer ফলাফল বিশ্লেষণ করবে এবং Report Writer চূড়ান্ত রিপোর্ট কম্পাইল করবে, যা পরে কনসোলে প্রিন্ট করা হয়। verbose=True সেটিং প্রতিটি এজেন্টের বিশদ চিন্তা প্রক্রিয়া এবং ক্রিয়া দেখাবে।

CrewAI সম্পর্কে আরও জানতে, CrewAI ভূমিকা দেখুন।