Autogen_v0.4/single_agent/single_agent_implementation.ipynb (229 lines of code) (raw):
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#%pip install azure-monitor-opentelemetry-exporter --pre"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"c:\\source\\repos\\multiagent-frameworks\\Autogen_v0.4\\single_agent\n"
]
}
],
"source": [
"import sys\n",
"import os\n",
"\n",
"# Get the current working directory (where the notebook is running)\n",
"notebook_dir = os.getcwd()\n",
"\n",
"# Add the parent directory to the system path\n",
"parent_dir = os.path.abspath(os.path.join(notebook_dir, '.'))\n",
"sys.path.append(parent_dir)\n",
"print(parent_dir)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# A Simple Chatbot that can respond directly to user questions. "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"c:\\source\\repos\\multiagent-frameworks\\Autogen_v0.4\n"
]
}
],
"source": [
"from single_agent_implementation import *\n",
"\n",
"from common.tracing_helper import *\n",
"\n",
"tracer_provider = get_trace_provider()\n",
"\n",
"tracer = tracer_provider.get_tracer(__name__)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Payment reversals occur when funds are sent back to the payer after a transaction. This may happen for various reasons, including disputes, fraudulent activity, technical errors, or refunds. On Transify, payment reversals can occur in scenarios like chargebacks initiated by a customer, refund requests, or compliance issues.\n",
"\n",
"### Common Reasons for Payment Reversals:\n",
"1. **Chargebacks:** When a customer disputes a transaction with their bank or card issuer.\n",
"2. **Fraudulent Transactions:** If unauthorized or suspicious activity is found.\n",
"3. **Customer Refunds:** When a seller agrees to return funds for goods or services.\n",
"4. **Processing Errors:** And mistakes in payment processing or account information.\n",
"\n",
"### How to Avoid Payment Reversals:\n",
"1. **Use Robust Fraud Detection Tools:** Employ Transify's fraud prevention and detection tools to reduce unauthorized transactions.\n",
"2. **Ensure Clear Communication and Documentation:** Provide accurate descriptions, terms of service, and refund policies for your goods or services.\n",
"3. **Deliver High-Quality Goods/Services:** Fulfill orders promptly and accurately to prevent customer disputes.\n",
"4. **Implement Secure Payment Methods:** Ensure that payments are securely processed and adhere to compliance guidelines.\n",
"5. **Keep Detailed Records:** Maintain all transaction-related records, including communications and delivery confirmations, for dispute resolution.\n",
"6. **Provide Excellent Customer Service:** Quickly address customer concerns to prevent dissatisfaction leading to disputes or chargebacks.\n",
"\n",
"If you face a payment reversal issue on Transify, you can contact our support team to investigate the case and discuss possible resolutions.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\source\\repos\\multiagent-frameworks\\Autogen_v0.4\\single_agent\\single_agent_implementation.py:35: UserWarning: Resolved model mismatch: gpt-4o-2024-08-06 != gpt-4o-2024-11-20. Model mapping in autogen_ext.models.openai may be incorrect.\n",
" completion = await self._model_client.create(self._chat_history)\n"
]
}
],
"source": [
"# send transify specific message to agent\n",
"\n",
"# Tracing Target Azure AppInsights - llm-appsights\n",
"\n",
"with tracer.start_span(\"running single agent scenario\"):\n",
" \n",
" # initialize runtime\n",
" runtime = SingleThreadedAgentRuntime(tracer_provider=tracer_provider)\n",
" \n",
" # register agents with the runtime\n",
" await register_agents(runtime)\n",
"\n",
" runtime.start()\n",
" \n",
" # send a message directly to the agent\n",
" agent_response = await runtime.send_message(transifyHelpAgentAMessage(body=UserMessage(content=\"What are payment reversals and how to avoid them\", source=\"user\")), recipient=AgentId(type=\"transifyHelpAgent\", key=\"transify_user1\")) \n",
" print(agent_response)\n",
"\n",
"\n",
"\n",
"#tracer_provider.force_flush()\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I’m sorry, but I can only respond to Transify-related queries. I cannot assist with planning a road trip. Do you have any questions related to Transify that I can help with?\n"
]
}
],
"source": [
"\n",
"# send out of context message to agent\n",
"\n",
"with tracer.start_span(\"running single agent scenario - out of domain message\"):\n",
" agent_response = await runtime.send_message(transifyHelpAgentAMessage(body=UserMessage(content=\"Plan a 3 day road trip to zion national park\", source=\"user\")), recipient=AgentId(type=\"transifyHelpAgent\", key=\"transify_user1\")) \n",
" print(agent_response)\n",
" #await runtime.stop_when_idle()\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"On Transify, reporting fraud is straightforward and essential to protect your account and transactions. If you suspect fraudulent activity, here's what you need to do:\n",
"\n",
"### Steps to Report Fraud on Transify:\n",
"1. **Log in to Your Account**:\n",
" - Visit the Transify platform and sign in to your account.\n",
"\n",
"2. **Navigate to the \"Security Center\"**:\n",
" - Go to your account settings and select the \"Security Center\" option from the menu.\n",
"\n",
"3. **Find the Fraud Reporting Tool**:\n",
" - In the \"Security Center,\" locate the option labeled \"Report Fraud or Suspicious Activity.\"\n",
"\n",
"4. **Provide Details**:\n",
" - Fill out the fraud reporting form with detailed information. Include:\n",
" - Transaction ID (if applicable)\n",
" - Date and time of the suspicious activity\n",
" - A description of what happened\n",
" - Any evidence or documentation supporting your claim\n",
"\n",
"5. **Submit the Report**:\n",
" - Review the information you’ve provided and click “Submit.” Transify’s fraud prevention team will review your case.\n",
"\n",
"### Additional Steps to Secure Your Account:\n",
"- **Change Your Password**: For safety, update your password immediately after detecting any fraudulent activity.\n",
"- **Enable 2-Factor Authentication (2FA)**: Activate 2FA in your Transify account to add an extra layer of protection.\n",
"- **Monitor Recent Transactions**: Check your transaction history for any unauthorized payments and report them promptly.\n",
"\n",
"### Need Further Assistance?\n",
"You can contact Transify’s dedicated fraud prevention team:\n",
"- **Email**: fraudprotection@transify.com\n",
"- **Support Line**: Reach out via the customer support phone number listed under \"Help & Support\" in your account.\n",
"\n",
"Transify takes fraud reports seriously and works diligently to resolve such issues. Let me know if you need help accessing any of these features!\n"
]
}
],
"source": [
"with tracer.start_span(\"running single agent scenario - in domain message\"):\n",
" agent_response = await runtime.send_message(transifyHelpAgentAMessage(body=UserMessage(content=\"how to report Fraud\", source=\"user\")), recipient=AgentId(type=\"transifyHelpAgent\", key=\"transify_user1\")) \n",
" print(agent_response)\n",
" #await runtime.stop_when_idle()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}