From 9cceb01f64bc268705efd155944c6f296e9bf5b1 Mon Sep 17 00:00:00 2001
From: Harry Ye <116691547+harryeqs@users.noreply.github.com>
Date: Thu, 23 Jan 2025 08:40:06 +0000
Subject: [PATCH] docs: Add OpenBB finanace Discord bot cookbook (#1490)
---
README.md | 1 +
.../applications/finance_discord_bot.ipynb | 620 ++++++++++++++++++
docs/cookbooks/applications/index.rst | 1 +
3 files changed, 622 insertions(+)
create mode 100644 docs/cookbooks/applications/finance_discord_bot.ipynb
diff --git a/README.md b/README.md
index 65a9fc518b..71004be9c9 100644
--- a/README.md
+++ b/README.md
@@ -290,6 +290,7 @@ Practical guides and tutorials for implementing specific functionalities in CAME
| **[Dynamic Travel Planner Role-Playing: Multi-Agent System with Real-Time Insights Powered by Dappier](https://docs.camel-ai.org/cookbooks/applications/dynamic_travel_planner.html)** | Explore an innovative approach to travel planning, blending AI-driven role-playing and real-time data for seamless experiences. |
| **[Customer Service Discord Bot with Agentic RAG](https://docs.camel-ai.org/cookbooks/applications/customer_service_Discord_bot_using_SambaNova_with_agentic_RAG.html)** | Learn how to build a robust customer service bot for Discord using Agentic RAG. |
| **[Customer Service Discord Bot with Local Model](https://docs.camel-ai.org/cookbooks/applications/customer_service_Discord_bot_using_local_model_with_agentic_RAG.html)** | Learn how to build a robust customer service bot for Discord using Agentic RAG which supports local deployment. |
+| **[Customer Service Discord Bot for Finance with OpenBB](https://docs.camel-ai.org/cookbooks/applications/finance_discord_bot.html)**| Learn how to build a sipmle yet powerful financial data assistant Discord bot using OpenBB tools. |
### Data Processing
| Cookbook | Description |
diff --git a/docs/cookbooks/applications/finance_discord_bot.ipynb b/docs/cookbooks/applications/finance_discord_bot.ipynb
new file mode 100644
index 0000000000..be2487f5e6
--- /dev/null
+++ b/docs/cookbooks/applications/finance_discord_bot.ipynb
@@ -0,0 +1,620 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "ymsq1Lw0VEqT"
+ },
+ "source": [
+ "# ๐ Customer Service Discord Bot for Finance with OpenBB\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "pyio4Bbedc26"
+ },
+ "source": [
+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1M0Zmynp5Mes1HP8zrDeF2_UI7aS9g3EJ?usp=sharing)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "G5gE04UuPUWj"
+ },
+ "source": [
+ "
\n",
+ "

\n",
+ "

\n",
+ " \n",
+ "โญ
Star us on [*Github*](https://github.com/camel-ai/camel), join our [*Discord*](https://discord.camel-ai.org) or follow our [*X*](https://x.com/camelaiorg)\n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "cv27y43GeNyC"
+ },
+ "source": [
+ "This notebook demonstrates how to build a custom financial assistant Discord bot using OpenBB and CAMEL-AI. By integrating real-time financial data and advanced AI-driven interactions, this tutorial showcases an innovative approach to delivering dynamic financial insights.\n",
+ "\n",
+ "In this notebook, you'll explore:\n",
+ "\n",
+ "- CAMEL-AI: A versatile multi-agent framework that powers the financial assistant with intelligent tool-calling and natural language understanding, ensuring precise and professional responses.\n",
+ "\n",
+ "- OpenBB: An open-source platform for advanced financial research, offering tools for analyzing stocks, cryptocurrencies, and market trends through an intuitive API integration.\n",
+ "\n",
+ "- Qwen: A large language model developed by Alibaba Cloud, used for generating intelligent and contextually aware responses in the assistant's interactions.\n",
+ "\n",
+ "- Discord Integration: A step-by-step guide to creating and deploying a chatbot in Discord, enabling seamless interaction with users and delivering financial insights in a community setting.\n",
+ "\n",
+ "This setup not only demonstrates a practical application of AI-driven financial assistance but also provides a robust framework adaptable to other domains requiring multi-agent collaboration, real-time data integration, and natural language interfaces."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "0J0_iW-YVcq2"
+ },
+ "source": [
+ "## ๐ฆ Installation"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "7p-JjpyNVcCT"
+ },
+ "source": [
+ "First, install the CAMEL package with all its dependencies:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1000
+ },
+ "collapsed": true,
+ "id": "WxSMW5r7OOVA",
+ "outputId": "6f77a6b4-8d09-4ee2-dc98-64d556dd4083"
+ },
+ "outputs": [],
+ "source": [
+ "!pip install \"camel-ai[all]==0.2.16\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "collapsed": true,
+ "id": "0GXs2pruU9Vl",
+ "outputId": "cdb146dd-3796-4e1f-bf0f-5e0c59bb4b48"
+ },
+ "outputs": [],
+ "source": [
+ "!pip install starlette\n",
+ "!pip install nest_asyncio"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "lfNvFbhD6o8B"
+ },
+ "source": [
+ "## ๐ Setting Up API Keys"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "jqV12oQfQTyl"
+ },
+ "source": [
+ "### Setting up Qwen API Key\n",
+ "In this tutorial, we will be using **Qwen** model. Qwen is a large language model developed by Alibaba Cloud. It is trained on a massive dataset of text and code and can generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way.\n",
+ "\n",
+ "You'll need to set up your API keys for Qwen. This ensures that the tools can interact with external services securely.\n",
+ "\n",
+ "If you don't have a Qwen API key, you can obtain one by following these steps:\n",
+ "1. Visit the Alibaba Cloud Model Studio Console (https://www.alibabacloud.com/en?_p_lc=1) and follow the on-screen instructions to activate the model services.\n",
+ "2. In the upper-right corner of the console, click on your account name and select API-KEY.\n",
+ "3. On the API Key management page, click on the Create API Key button to generate a new key.\n",
+ "\n",
+ "For more details, you can also check the Qwen documentation: https://www.alibabacloud.com/help/en/model-studio/developer-reference/use-qwen-by-calling-api"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "0fjiZHnW4Uve",
+ "outputId": "a24506cc-be2a-459d-cc8b-e733cee983ff"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enter your API key: ยทยทยทยทยทยทยทยทยทยท\n"
+ ]
+ }
+ ],
+ "source": [
+ "import os\n",
+ "from getpass import getpass\n",
+ "\n",
+ "qwen_api_key = getpass('Enter your API key: ')\n",
+ "os.environ[\"QWEN_API_KEY\"] = qwen_api_key"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "2xM10-BCgPXf"
+ },
+ "source": [
+ "To use Qwen model with CAMEL, we need to set up the model first:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "H6q5xbQtajUj"
+ },
+ "outputs": [],
+ "source": [
+ "from camel.configs import QwenConfig, MistralConfig\n",
+ "from camel.models import ModelFactory\n",
+ "from camel.types import ModelPlatformType, ModelType\n",
+ "\n",
+ "qwen_model = ModelFactory.create(\n",
+ " model_platform=ModelPlatformType.QWEN,\n",
+ " model_type=ModelType.QWEN_TURBO,\n",
+ " model_config_dict=QwenConfig(temperature=0.2).as_dict(),\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "tUn0KTSPpL4E"
+ },
+ "source": [
+ "## Setting up OpenBB Personal Access Token (PAT)\n",
+ "**OpenBB** is an open-source platform designed for advanced investment research, empowering users with tools to analyze financial data, create visualizations, and generate detailed reports. Catering to retail investors, financial analysts, and enthusiasts, OpenBB provides access to functionalities typically available only on expensive institutional platforms. It supports stock data exploration, portfolio analysis, market trend evaluation, and integration with premium APIs, all through an intuitive terminal or command-line interface.\n",
+ "\n",
+ "**CAMEL** has integrated an **OpenBB toolkit** that allows CAMEL agents to access plenty of OpenBB's powerful functions easily. For more information about the toolkit, please refer to the [documentation](https://docs.camel-ai.org/camel.toolkits.html#camel.toolkits.OpenBBToolkit).\n",
+ "\n",
+ "To use the toolkit, we would need an OpennBB Personal Access Token (PAT).\n",
+ "\n",
+ "### How to obtain an OpenBB PAT\n",
+ "1. Please login to the [OpenBB Platform](https://my.openbb.co/app/platform/examples) or sign up as prompted if you do not have an account yet.\n",
+ "2. In 'SETTINGS', go to 'Personal Access Token'.\n",
+ "3. You can now see your OpenBB personal access token (PAT).\n",
+ "\n",
+ "Please refer to OpenBBโs documentation for more details.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "IiCYLblgpK5h",
+ "outputId": "673c227d-4fc5-4441-d35e-8c456f580518"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enter your OpenBB PAT: ยทยทยทยทยทยทยทยทยทยท\n"
+ ]
+ }
+ ],
+ "source": [
+ "openbb_pat = getpass(\"Enter your OpenBB PAT: \")\n",
+ "os.environ[\"OPENBB_TOKEN\"] = openbb_pat"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "1YPXhOO7wiui"
+ },
+ "source": [
+ "## Set up Agent Equipped with OpenBB and date tools\n",
+ "In this step, we will define the tools and the system prompt for our `ChatAgent`.\n",
+ "\n",
+ "Since the LLMs do not instrinsically know the current dates, we need to define a date tool to get the current date.\n",
+ "\n",
+ "Below we also set the prompt to pass into the agent for better tool calling and output formatting."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ukAya-TiwoHr",
+ "outputId": "a07e42fa-60eb-4a11-9643-c1d2f3714667"
+ },
+ "outputs": [],
+ "source": [
+ "from camel.agents import ChatAgent\n",
+ "from camel.toolkits import OpenBBToolkit, FunctionTool\n",
+ "from datetime import date\n",
+ "\n",
+ "OPENBB_AGENT_SYSTEM_PROMPT = \"\"\"\n",
+ "You are a helpful assistant providing detailed financial data, including stocks, coins, and similar assets, using OpenBB tools and the date tool.\n",
+ "\n",
+ "Role:\n",
+ " - Deliver accurate, data-driven responses about financial assets using structured ASCII tables.\n",
+ "\n",
+ "Objective:\n",
+ " 1. Answer asset-specific queries concisely and professionally.\n",
+ " 2. Always display the current date prominently and interpret relative dates accurately.\n",
+ " 3. Use ASCII tables for all data summaries.\n",
+ "\n",
+ "Instructions:\n",
+ " 1. Input Validation:\n",
+ " - Confirm the query is specific to an asset (e.g., stock, coin, or similar).\n",
+ " - If unclear, request clarification (e.g., \"Could you specify which asset you're referring to?\").\n",
+ "\n",
+ " 2. Date Awareness:\n",
+ " - Dynamically fetch and display the current date for context in all responses.\n",
+ " - Interpret relative dates (e.g., \"yesterday,\" \"last week\") accurately:\n",
+ " - \"Yesterday\": Subtract one day from the current date.\n",
+ " - \"Last week\": Provide the range for the previous 7 days from the current date.\n",
+ " - Ensure the calculated date or date range is clearly displayed.\n",
+ "\n",
+ " 3. Symbol Handling:\n",
+ " - Extract the ticker symbol or lookup based on the asset name.\n",
+ " - Correct misspellings or broaden the search scope if necessary.\n",
+ "\n",
+ " 4. Information Retrieval:\n",
+ " - Fetch key metrics (e.g., PE ratio, market cap, price trends, trading volume) using the tools in the OpenBB toolkit.\n",
+ " - If no data could be retrieved using the OpenBB tools, kindly inform the user.\n",
+ " - Avoid reliance on FMP for data.\n",
+ "\n",
+ " 5. Response Composition:\n",
+ " - Use a professional tone and concise formatting.\n",
+ " - Represent all data in clean ASCII tables with proper alignment and headers.\n",
+ "\n",
+ "Output Guidelines:\n",
+ " 1. Enhanced ASCII Table Format:\n",
+ " Example:\n",
+ " ```\n",
+ " +--------+-------------------+--------+-----------+----------+-------------+\n",
+ " | Symbol | Asset | Price | Change ($)| % Change | Volume |\n",
+ " +--------+-------------------+--------+-----------+----------+-------------+\n",
+ " | MSFT | Microsoft Stock | $320.11| -$3.25 | -1.01% | 19,000,000 |\n",
+ " | BTC | Bitcoin | $28,550| +$150 | +0.53% | 22,000 BTC |\n",
+ " +--------+-------------------+--------+-----------+----------+-------------+\n",
+ " ```\n",
+ "\n",
+ " 2. Current Date and Context:\n",
+ " - Prominently include the current date or inferred relative date in all responses:\n",
+ " - Example:\n",
+ " *Query:* \"Show data for yesterday.\"\n",
+ " *Response:* \"The data for 2025-01-21 (yesterday) is as follows:\"\n",
+ "\n",
+ "By following these enhanced instructions, provide clear, accurate, and professional financial data summaries for stocks, coins, and similar assets without graphical visualizations, while incorporating dynamic date awareness.\n",
+ "\"\"\"\n",
+ "\n",
+ "\n",
+ "# Define the date tool\n",
+ "def get_today_date():\n",
+ " r\"\"\"Get the date of today.\"\"\"\n",
+ " return date.today()\n",
+ "\n",
+ "# Set up tools to be used\n",
+ "openbb_toolkit = OpenBBToolkit()\n",
+ "openbb_tools = openbb_toolkit.get_tools()\n",
+ "date_tool = [FunctionTool(get_today_date)]\n",
+ "\n",
+ "# Set up ChatAgent with defined prompt and tools\n",
+ "openbb_agent = ChatAgent(\n",
+ " system_message=OPENBB_AGENT_SYSTEM_PROMPT,\n",
+ " model=qwen_model,\n",
+ " tools=openbb_tools + date_tool\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "OPr97YkP8yir"
+ },
+ "source": [
+ "## Basic Chatbot Setup\n",
+ "Let's set up the basic Chatbot with CAMEL Agent equipped with OpenBB and date tools and ask some questions!\n",
+ "\n",
+ "For example, we can ask:\n",
+ "\n",
+ "*What was the price of Tesla yesterday?*"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "ENfY2uoV8xh4",
+ "outputId": "702d65f1-e10f-4bbc-db29-370c3ab485d5"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Start chatting! Type 'exit' to end the conversation.\n",
+ "User: What was the price of Tesla yesterday?\n",
+ "Tool call: [FunctionCallingRecord(func_name='get_today_date', args={}, result=datetime.date(2025, 1, 22)), FunctionCallingRecord(func_name='get_historical_data', args={'symbol': 'TSLA', 'provider': 'yfinance', 'asset_type': 'equity', 'start_date': '2025-01-21', 'end_date': '2025-01-21', 'interval': '1d'}, result=[YFinanceEquityHistoricalData(date=2025-01-21, open=432.6400146484375, high=433.20001220703125, low=406.30999755859375, close=424.07000732421875, volume=86980300, vwap=None, split_ratio=None, dividend=None)])]\n",
+ "Assistant: The price of Tesla (TSLA) on 2025-01-21 (yesterday) was as follows:\n",
+ "\n",
+ "```\n",
+ "+------------+--------+--------+---------+---------+---------+------+\n",
+ "| Date | Open | High | Low | Close | Volume | VWAP |\n",
+ "+------------+--------+--------+---------+---------+---------+------+\n",
+ "| 2025-01-21 | $432.64| $433.20| $406.31 | $424.07 | 86,980,300 | N/A |\n",
+ "+------------+--------+--------+---------+---------+---------+------+\n",
+ "```\n",
+ "\n",
+ "Please note that the Volume Weighted Average Price (VWAP) is not provided in this dataset. The figures shown are the opening, highest, lowest, closing prices, and the trading volume for the specified date.\n",
+ "User: exit\n",
+ "Ending conversation.\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"Start chatting! Type 'exit' to end the conversation.\")\n",
+ "while True:\n",
+ " user_input = input(\"User: \")\n",
+ "\n",
+ " if user_input.lower() == \"exit\":\n",
+ " print(\"Ending conversation.\")\n",
+ " break\n",
+ "\n",
+ " assistant_response = openbb_agent.step(user_input)\n",
+ " print(f\"Tool call: {assistant_response.info['tool_calls']}\")\n",
+ " print(f\"Assistant: {assistant_response.msgs[0].content}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "Qub28k5cOLIJ"
+ },
+ "source": [
+ "As we can see above in the tool call records, the agent automatically identify which tools to use and accurately utilizes the tools to retrive relevant data."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "KEoZ057EyLXc"
+ },
+ "source": [
+ "## Basic Discord Bot Integration"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "EFotwN38zX5S"
+ },
+ "source": [
+ "To build a discord bot, a discord bot token is necessary.\n",
+ "\n",
+ "If you don't have a bot token, you can obtain one by following these steps:\n",
+ "1. Go to the Discord Developer Portal:https://discord.com/developers/applications\n",
+ "2. Log in with your Discord account, or create an account if you don't have one\n",
+ "3. Click on 'New Application' to create a new bot.\n",
+ "4. Give your application a name and click 'Create'.\n",
+ "5. Navigate to the 'Bot' tab on the left sidebar and click 'Add Bot'.\n",
+ "6. Once the bot is created, you will find a 'Token' section. Click 'Reset Token' to generate a new token.\n",
+ "7. Copy the generated token securely.\n",
+ "\n",
+ "To invite the bot:\n",
+ "1. Navigate to the 'OAuth2' tab, then to 'URL Generator'.\n",
+ "2. Under 'Scopes', select 'bot'.\n",
+ "3. Under 'Bot Permissions', select the permissions your bot will need (e.g., 'Send Messages', 'Read Messages' for our bot use)\n",
+ "4. Copy the generated URL and paste it into your browser to invite the bot to your server.\n",
+ "\n",
+ "To grant the bot permissions:\n",
+ "1. Navigate to the 'Bot' tab\n",
+ "2. Under 'Privileged Gateway Intents', check 'Server Members Intent' and 'Message Content Intent'.\n",
+ "\n",
+ "For more details, you can also check the official Discord bot documentation: https://discord.com/developers/docs/intro\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "o1DZU0wniM8V",
+ "outputId": "a8cc9c91-7699-4039-8c5a-919954bc986f"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enter your Discord bot token: ยทยทยทยทยทยทยทยทยทยท\n"
+ ]
+ }
+ ],
+ "source": [
+ "import os\n",
+ "from getpass import getpass\n",
+ "\n",
+ "discord_bot_token = getpass('Enter your Discord bot token: ')\n",
+ "os.environ[\"DISCORD_BOT_TOKEN\"] = discord_bot_token"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "xNPmN-RzF64T"
+ },
+ "source": [
+ "\n",
+ "This code cell sets up a simple Discord bot using the DiscordApp class from the `camel.bots` library. The bot listens for messages in any channel it has access to and provides a response based on the input message."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "collapsed": true,
+ "id": "ildOUaM6iSW5",
+ "outputId": "eaa244bd-4ac3-4ef7-e0cc-a8acd096b93a"
+ },
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "\u001b[30;1m2025-01-22 14:00:20\u001b[0m \u001b[34;1mINFO \u001b[0m \u001b[35mdiscord.client\u001b[0m logging in using static token\n",
+ "\u001b[30;1m2025-01-22 14:00:20\u001b[0m \u001b[34;1mINFO \u001b[0m \u001b[35mdiscord.client\u001b[0m logging in using static token\n",
+ "INFO:discord.client:logging in using static token\n",
+ "\u001b[30;1m2025-01-22 14:00:21\u001b[0m \u001b[34;1mINFO \u001b[0m \u001b[35mdiscord.gateway\u001b[0m Shard ID None has connected to Gateway (Session ID: a3152507afb8c3a4fb097fa05c02005d).\n",
+ "\u001b[30;1m2025-01-22 14:00:21\u001b[0m \u001b[34;1mINFO \u001b[0m \u001b[35mdiscord.gateway\u001b[0m Shard ID None has connected to Gateway (Session ID: a3152507afb8c3a4fb097fa05c02005d).\n",
+ "INFO:discord.gateway:Shard ID None has connected to Gateway (Session ID: a3152507afb8c3a4fb097fa05c02005d).\n"
+ ]
+ }
+ ],
+ "source": [
+ "from camel.bots import DiscordApp\n",
+ "import nest_asyncio\n",
+ "import discord\n",
+ "\n",
+ "nest_asyncio.apply()\n",
+ "discord_bot = DiscordApp(token=discord_bot_token)\n",
+ "\n",
+ "@discord_bot.client.event\n",
+ "async def on_message(message: discord.Message):\n",
+ " if message.author == discord_bot.client.user:\n",
+ " return\n",
+ "\n",
+ " if message.type != discord.MessageType.default:\n",
+ " return\n",
+ "\n",
+ " if message.author.bot:\n",
+ " return\n",
+ " user_input = message.content\n",
+ "\n",
+ " assistant_response = openbb_agent.step(user_input)\n",
+ "\n",
+ " response_content = assistant_response.msgs[0].content\n",
+ "\n",
+ " if len(response_content) > 2000: # discord message length limit\n",
+ " for chunk in [response_content[i:i+2000] for i in range(0, len(response_content), 2000)]:\n",
+ " await message.channel.send(chunk)\n",
+ " else:\n",
+ " await message.channel.send(response_content)\n",
+ "\n",
+ "discord_bot.run()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "Csg24PU8O75j"
+ },
+ "source": [
+ "Here is an example run of the bot -- with a concise and nicely formatted response!\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "kd2EhVQbP84S"
+ },
+ "source": [
+ "And let's try another question\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "5LS3u3aoQvru"
+ },
+ "source": [
+ "Here we go! In this cookbook, weโve built a simple yet powerful financial data assistant bot using **OpenBB** tools, which enables quick access to the latest financial data through natural language queries."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "xerDlirc1nx2"
+ },
+ "source": [
+ "That's everything: Got questions about ๐ซ CAMEL-AI? Join us on [Discord](https://discord.camel-ai.org)! Whether you want to share feedback, explore the latest in multi-agent systems, get support, or connect with others on exciting projects, weโd love to have you in the community! ๐ค\n",
+ "\n",
+ "Check out some of our other work:\n",
+ "1. ๐ซ Creating Your First CAMEL Agent [free Colab](https://docs.camel-ai.org/cookbooks/create_your_first_agent.html)\n",
+ "2. Graph RAG Cookbook [free Colab](https://colab.research.google.com/drive/1uZKQSuu0qW6ukkuSv9TukLB9bVaS1H0U?usp=sharing)\n",
+ "3. ๐งโโ๏ธ Create A Hackathon Judge Committee with Workforce [free Colab](https://colab.research.google.com/drive/18ajYUMfwDx3WyrjHow3EvUMpKQDcrLtr?usp=sharing)\n",
+ "4. ๐ฅ 3 ways to ingest data from websites with Firecrawl & CAMEL [free Colab](https://colab.research.google.com/drive/1lOmM3VmgR1hLwDKdeLGFve_75RFW0R9I?usp=sharing)\n",
+ "5. ๐ฆฅ Agentic SFT Data Generation with CAMEL and Mistral Models, Fine-Tuned with Unsloth [free Colab](https://colab.research.google.com/drive/1lYgArBw7ARVPSpdwgKLYnp_NEXiNDOd-?usp=sharingg)\n",
+ "\n",
+ "Thanks from everyone at ๐ซ CAMEL-AI\n",
+ "\n",
+ "\n",
+ "\n",
+ "

\n",
+ "

\n",
+ " \n",
+ "โญ
Star us on Github , join our [*Discord*](https://discord.camel-ai.org) or follow our [*X*](https://x.com/camelaiorg) โญ\n",
+ "
\n"
+ ]
+ }
+ ],
+ "metadata": {
+ "accelerator": "GPU",
+ "colab": {
+ "gpuType": "T4",
+ "provenance": []
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/docs/cookbooks/applications/index.rst b/docs/cookbooks/applications/index.rst
index 5b0eb5ad54..60c7b95e8a 100644
--- a/docs/cookbooks/applications/index.rst
+++ b/docs/cookbooks/applications/index.rst
@@ -16,3 +16,4 @@ Applications
customer_service_Discord_bot_with_agentic_RAG
customer_service_Discord_bot_using_SambaNova_with_agentic_RAG
customer_service_Discord_bot_using_local_model_with_agentic_RAG
+ finance_discord_bot
\ No newline at end of file