{"id":1629,"date":"2024-11-15T08:06:00","date_gmt":"2024-11-15T00:06:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1629"},"modified":"2024-10-23T16:59:24","modified_gmt":"2024-10-23T08:59:24","slug":"ollama-%e5%87%ba%e9%a9%ac%ef%bc%8c%e4%b8%ba%e4%bd%a0%e5%88%9b%e5%bb%ba%e5%ae%9e%e6%97%b6-ai-%e8%82%a1%e7%a5%a8%e9%a1%be%e9%97%ae","status":"publish","type":"post","link":"https:\/\/www.laoyulaoyu.com\/index.php\/2024\/11\/15\/ollama-%e5%87%ba%e9%a9%ac%ef%bc%8c%e4%b8%ba%e4%bd%a0%e5%88%9b%e5%bb%ba%e5%ae%9e%e6%97%b6-ai-%e8%82%a1%e7%a5%a8%e9%a1%be%e9%97%ae\/","title":{"rendered":"Ollama \u51fa\u9a6c\uff0c\u4e3a\u4f60\u521b\u5efa\u5b9e\u65f6 AI \u80a1\u7968\u987e\u95ee"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/10\/101802.png\" alt=\"\" class=\"wp-image-2601\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u672c\u6587\u4f1a\u4ecb\u7ecd\u4e00\u4e2a<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u5229\u7528\u5927\u6a21\u578b LLM\uff08Ollama Llama 3\uff09\u548c Streamlit \u5f00\u53d1\u7684\u5b9e\u65f6\u4eba\u5de5\u667a\u80fd\u80a1\u7968\u987e\u95ee\u9879\u76ee<\/mark>\uff0c\u8be5\u987e\u95ee\u76ee\u524d\u80fd\u591f\u505a\u5230\u6bcf\u5206\u949f\u83b7\u53d6\u80a1\u7968\u6570\u636e\uff0c\u5206\u6790\u8d8b\u52bf\uff0c\u5e76\u4e3a\u60a8\u63d0\u4f9b\u6613\u4e8e\u7406\u89e3\u7684\u5b9e\u65f6\u89e3\u91ca\u3002<\/pre>\n<\/blockquote>\n\n\n\n<p>\u524d\u9635\u5b50\u4e3a\u4e00\u4e2a\u667a\u6167\u91d1\u878d\u9879\u76ee\u5236\u4f5c\u80a1\u7968\u6570\u636e\u53ef\u89c6\u5316\u90e8\u7f72 AI\u80fd\u529b\u65f6\uff0c\u6211\u7a81\u7136\u5192\u51fa\u4e2a\u60f3\u6cd5\uff1a\u8981\u662f\u6570\u636e\u80fd\u81ea\u5df1\u7528\u901a\u4fd7\u6613\u61c2\u7684\u8bdd\u6765\u89e3\u91ca\uff0c\u90a3\u8be5\u591a\u597d\u554a\uff01\u4e8e\u662f\uff0c\u6211\u5c31\u5f00\u59cb\u5c1d\u8bd5\u505a\u8fd9\u4e2a\u3002\u8fd9\u4e2a\u811a\u672c\u5229\u7528 LLM \u9a71\u52a8\uff08Llama 3\uff09\u7684\u6d1e\u5bdf\u529b\uff0c\u6bcf\u5206\u949f\u83b7\u53d6\u80a1\u7968\u6570\u636e\uff0c\u5206\u6790\u8d8b\u52bf\uff0c\u7136\u540e\u7ed9\u51fa\u7b80\u5355\u6613\u61c2\u7684\u89e3\u91ca\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u518d\u4e5f\u4e0d\u7528\u772f\u7740\u773c\u775b\u770b\u56fe\u8868\u5566 \u2014\u2014 \u5c31\u50cf\u6709\u4e2a\u79c1\u4eba\u80a1\u7968\u4e13\u5bb6\u5728\u8eab\u8fb9\uff0c\u968f\u65f6\u4e3a\u4f60\u5206\u6790\u6b63\u5728\u53d1\u751f\u7684\u4e8b\u60c5\u3002\u95f2\u8bdd\u4e0d\u591a\u626f\u4e86\uff0c\u6211\u4eec\u76f4\u63a5\u8fdb\u5165\u6b63\u9898\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u6b65\u9aa4 1\uff1a\u8bbe\u7f6e\u73af\u5883<\/strong><\/h3>\n\n\n\n<p>\u5728\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5b89\u88c5\u51e0\u4e2a\u5173\u952e\u5e93\uff0c\u5b83\u4eec\u5c06\u4f7f\u672c\u9879\u76ee\u6210\u4e3a\u53ef\u80fd\u3002\u6211\u4eec\u5c06\u4f7f\u7528 Streamlit \u521b\u5efa\u7528\u6237\u754c\u9762\uff0c\u4f7f\u7528 yfinance \u83b7\u53d6\u80a1\u7968\u6570\u636e\uff0c\u4f7f\u7528 Ollama \u751f\u6210\u81ea\u7136\u8bed\u8a00\u89c1\u89e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>import streamlit as st\nimport yfinance as yf\nimport pandas as pd\nimport schedule\nimport time\nimport ollama\nfrom datetime import datetime, timedelta<\/code><\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u8fd8\u6709\u540c\u5b66\u4e0d\u77e5\u9053<strong> Streamlit<\/strong> \u662f\u5565\u4e1c\u4e1c\uff0c\u6211\u7b80\u5355\u7684\u89e3\u91ca\u4e0b\uff1a<\/p>\n\n\n\n<p>Streamlit\u662f\u4e00\u4e2a\u57fa\u4e8ePython\u7684Web\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff0c\u4e13\u4e3a\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u9886\u57df\u7684\u5feb\u901f\u5e94\u7528\u5f00\u53d1\u800c\u8bbe\u8ba1\u3002\u5b83\u7b80\u5316\u4e86\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u5e94\u7528\u7684\u5f00\u53d1\u8fc7\u7a0b\uff0c\u4f7f\u5f97\u7528\u6237\u80fd\u591f\u66f4\u5feb\u5730\u6784\u5efa\u548c\u90e8\u7f72\u4ea4\u4e92\u5f0f\u3001\u53ef\u89c6\u5316\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u65e0\u8bba\u662f\u5bf9\u4e8e\u6570\u636e\u79d1\u5b66\u5bb6\u3001\u673a\u5668\u5b66\u4e60\u5de5\u7a0b\u5e08\u8fd8\u662f\u6559\u80b2\u5de5\u4f5c\u8005\u6765\u8bf4\uff0cStreamlit\u90fd\u662f\u4e00\u4e2a\u503c\u5f97\u5c1d\u8bd5\u7684\u5de5\u5177\u3002<br>Streamlit\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u4e0e\u5b89\u88c5\u5176\u4ed6Python\u5305\u7c7b\u4f3c\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7pip\u547d\u4ee4\u8f7b\u677e\u5b89\u88c5\u3002\u4f7f\u7528Streamlit\u65f6\uff0c\u7528\u6237\u53ea\u9700\u7f16\u5199Python\u811a\u672c\uff0c\u5e76\u5728\u811a\u672c\u4e2d\u8c03\u7528Streamlit\u7684API\u6765\u521b\u5efa\u754c\u9762\u5143\u7d20\u548c\u903b\u8f91\u3002\u5b8c\u6210\u7f16\u5199\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528Streamlit\u7684\u547d\u4ee4\u884c\u5de5\u5177\u6765\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u548c\u4ea4\u4e92\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"f5de\"><strong>\u6b65\u9aa4 2\uff1a\u83b7\u53d6\u5e93\u5b58\u6570\u636e\u8fdb\u884c\u5206\u6790<\/strong><\/h3>\n\n\n\n<p id=\"3af1\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u83b7\u53d6\u82f9\u679c\u516c\u53f8 (AAPL) \u548c\u9053\u743c\u65af\u6307\u6570 (DJI) \u7684\u5386\u53f2\u80a1\u7968\u6570\u636e\u3002\u6211\u4eec\u5c06\u4f7f\u7528 yfinance \u4ee5 1 \u5206\u949f\u4e3a\u95f4\u9694\u83b7\u53d6\u524d\u4e00\u5929\u7684\u80a1\u7968\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code># Fetching historical data for Apple (AAPL) and Dow Jones (DJI)\nstock = yf.Ticker(\"AAPL\")\ndow_jones = yf.Ticker(\"^DJI\")\ndata = stock.history(period=\"1d\", interval=\"1m\")\ndow_data = dow_jones.history(period=\"1d\", interval=\"1m\")<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\" id=\"e2ff\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.readmedium.com\/v2\/resize:fit:800\/0*SkONptsXd2ekziFa.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"a879\">\u5728\u8fd9\u4e2a\u9636\u6bb5\uff0c\u6211\u4eec\u5df2\u7ecf\u638c\u63e1\u4e86\u80a1\u7968\u6570\u636e\uff0c\u5e76\u5c06\u5229\u7528\u8fd9\u4e9b\u6570\u636e\u8fdb\u884c\u8fdb\u4e00\u6b65\u5206\u6790\u3002\u4e3a\u4e86\u4fbf\u4e8e\u6f14\u793a\uff0c\u6211\u4f7f\u7528\u4e86\u4e0a\u4e00\u4e2a\u4ea4\u6613\u65e5\u7684\u6570\u636e\u3002<strong>\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5df1\u6765\u8c03\u6574\uff0c\u76f4\u63a5\u4ece\u5e94\u7528\u7a0b\u5e8f\u63a5\u53e3\u83b7\u53d6\u5b9e\u65f6\u80a1\u7968\u6570\u636e\uff0c\u5904\u7406\u5b9e\u65f6\u5e02\u573a\u66f4\u65b0\u3002<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"f909\"><strong>\u6b65\u9aa4 3\uff1a\u5904\u7406\u5b9e\u65f6\u5e93\u5b58\u66f4\u65b0<\/strong><\/h3>\n\n\n\n<p id=\"2591\">\u73b0\u5728\u8ba9\u6211\u4eec\u901a\u8fc7\u6bcf\u5206\u949f\u5904\u7406\u4e00\u4e2a\u80a1\u7968\u6570\u636e\u70b9\u6765\u6a21\u62df\u5b9e\u65f6\u66f4\u65b0\u3002\u6211\u4eec\u5c06\u8ba1\u7b97\u6eda\u52a8\u5e73\u5747\u7ebf\u548c\u52a8\u91cf\u7b49\u6307\u6807\uff0c\u4ee5\u4e86\u89e3\u5e02\u573a\u8d8b\u52bf\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code># Global variables to store rolling data\nrolling_window = pd.DataFrame()\ndow_rolling_window = pd.DataFrame()\ndaily_high = float('-inf')\ndaily_low = float('inf')\nbuying_momentum = 0\nselling_momentum = 0\n\n# Function to process a new stock update every minute\ndef process_stock_update():\n    global rolling_window, data, dow_rolling_window, dow_data\n    global daily_high, daily_low, buying_momentum, selling_momentum\n\n    if not data.empty and not dow_data.empty:\n        # Simulate receiving a new data point for AAPL and Dow Jones\n        update = data.iloc&#91;0].to_frame().T\n        dow_update = dow_data.iloc&#91;0].to_frame().T\n        data = data.iloc&#91;1:]  # Remove the processed row\n        dow_data = dow_data.iloc&#91;1:]\n\n        # Append the new data points to the rolling windows\n        rolling_window = pd.concat(&#91;rolling_window, update], ignore_index=False)\n        dow_rolling_window = pd.concat(&#91;dow_rolling_window, dow_update], ignore_index=False)\n\n        # Update daily high and low\n        daily_high = max(daily_high, update&#91;'Close'].values&#91;0])\n        daily_low = min(daily_low, update&#91;'Close'].values&#91;0])\n\n        # Calculate momentum\n        if len(rolling_window) &gt;= 2:\n            price_change = update&#91;'Close'].values&#91;0] - rolling_window&#91;'Close'].iloc&#91;-2]\n            if price_change &gt; 0:\n                buying_momentum += price_change\n            else:\n                selling_momentum += abs(price_change)<\/code><\/code><\/pre>\n\n\n\n<p id=\"0cc1\">\u6bcf\u4e2a\u65b0\u6570\u636e\u70b9\u90fd\u4f1a\u6dfb\u52a0\u5230 5 \u5206\u949f\u5206\u6790\u7684\u6eda\u52a8\u7a97\u53e3\u4e2d\u3002\u6bcf\u65e5\u6700\u9ad8\/\u6700\u4f4e\u503c\u548c\u4ef7\u683c\u52a8\u91cf\u4f1a\u6839\u636e\u8fde\u7eed\u6570\u636e\u70b9\u4e4b\u95f4\u7684\u53d8\u5316\u8fdb\u884c\u66f4\u65b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"955d\"><strong>\u6b65\u9aa4 4\uff1a\u5206\u6790\u80a1\u7968\u8d70\u52bf<\/strong><\/h3>\n\n\n\n<p id=\"ca07\">\u4e3a\u4e86\u7406\u89e3\u5b9e\u65f6\u6570\u636e\uff0c<strong>\u6211\u4eec\u4f1a\u8ba1\u7b97\u79fb\u52a8\u5e73\u5747\u7ebf\u3001\u4ef7\u683c\u53d8\u5316\u3001\u6210\u4ea4\u91cf\u53d8\u5316\u4ee5\u53ca\u6307\u6570\u79fb\u52a8\u5e73\u5747\u7ebf (EMA)\u3001\u5e03\u6797\u5e26\u548c RSI\uff08\u76f8\u5bf9\u5f3a\u5f31\u6307\u6570\uff09\u7b49\u6280\u672f\u6307\u6807<\/strong>\u3002\u4ee5\u4e0b\u662f\u8fd9\u4e9b\u6307\u6807\u7684\u5de5\u4f5c\u539f\u7406\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6307\u6570\u79fb\u52a8\u5e73\u5747\u7ebf (EMA)\uff1a<\/strong>\u66f4\u770b\u91cd\u8fd1\u671f\u4ef7\u683c\uff0c\u4ee5\u8bc6\u522b\u77ed\u671f\u8d8b\u52bf\u3002<\/li>\n\n\n\n<li><strong>\u76f8\u5bf9\u5f3a\u5f31\u6307\u6570\uff08RSI\uff09\uff1a<\/strong>\u8861\u91cf\u4ef7\u683c\u53d8\u52a8\u901f\u5ea6\uff0c\u5728 0 \u548c 100 \u4e4b\u95f4\u9707\u8361\uff0c\u4ee5\u786e\u5b9a\u8d85\u4e70\/\u8d85\u5356\u60c5\u51b5\u3002<\/li>\n\n\n\n<li><strong>\u5e03\u6797\u7ebf\uff1a<\/strong>\u5229\u7528\u79fb\u52a8\u5e73\u5747\u7ebf\u9644\u8fd1\u7684\u4e0a\u4e0b\u9650\u5e26\u5e2e\u52a9\u8bc4\u4f30\u5e02\u573a\u6ce2\u52a8\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def calculate_insights(window, dow_window):\n    if len(window) &gt;= 5:\n        # 5-minute rolling average\n        rolling_avg = window&#91;'Close'].rolling(window=5).mean().iloc&#91;-1]\n        \n        # Exponential Moving Average (EMA)\n        ema = window&#91;'Close'].ewm(span=5, adjust=False).mean().iloc&#91;-1]\n        \n        # Bollinger Bands (using a 5-period window)\n        std = window&#91;'Close'].rolling(window=5).std().iloc&#91;-1]\n        bollinger_upper = rolling_avg + (2 * std)\n        bollinger_lower = rolling_avg - (2 * std)\n\n        # RSI calculation\n        delta = window&#91;'Close'].diff()\n        gain = delta.where(delta &gt; 0, 0)\n        loss = -delta.where(delta &lt; 0, 0)\n        avg_gain = gain.rolling(window=14, min_periods=1).mean().iloc&#91;-1]\n        avg_loss = loss.rolling(window=14, min_periods=1).mean().iloc&#91;-1]\n        rs = avg_gain \/ avg_loss if avg_loss != 0 else float('nan')\n        rsi = 100 - (100 \/ (1 + rs))\n\n        # Calculate Relative Strength Index (RSI) if there are enough periods (14 is typical)\n        delta = window&#91;'Close'].diff()\n        gain = delta.where(delta &gt; 0, 0)\n        loss = -delta.where(delta &lt; 0, 0)\n        avg_gain = gain.rolling(window=14, min_periods=1).mean().iloc&#91;-1]\n        avg_loss = loss.rolling(window=14, min_periods=1).mean().iloc&#91;-1]\n        rs = avg_gain \/ avg_loss if avg_loss != 0 else float('nan')\n        rsi = 100 - (100 \/ (1 + rs))\n\n        # Calculate Dow Jones index rolling average\n        dow_rolling_avg = dow_window&#91;'Close'].rolling(window=5).mean().iloc&#91;-1]\n        \n        market_open_duration = get_market_open_duration(window)\n        if int(market_open_duration) % 5 == 0:  # Trigger LLM every 5 minutes\n            get_natural_language_insights(\n                rolling_avg, ema, rsi, bollinger_upper, bollinger_lower,\n                price_change, volume_change, dow_rolling_avg, market_open_duration, \n                dow_price_change, dow_volume_change, daily_high, daily_low, \n                buying_momentum, selling_momentum\n            )<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\" id=\"a2e5\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.readmedium.com\/v2\/resize:fit:800\/0*gA3OREfypUFbcCjp.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"8102\"><strong><br>\u6b65\u9aa4 5\uff1a\u4f7f\u7528 Ollama \u83b7\u53d6\u81ea\u7136\u8bed\u8a00\u89e3\u91ca<\/strong><\/h3>\n\n\n\n<p id=\"c428\">\u4e3a\u4e86\u4f7f\u8be5\u9879\u76ee\u66f4\u5177\u4e92\u52a8\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u6574\u5408\u4e86\u514d\u8d39\u7684 Llama 3 \u6a21\u578b\uff0c\u6bcf 5 \u5206\u949f\u751f\u6210\u4e00\u6b21\u81ea\u7136\u8bed\u8a00\u89c1\u89e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def get_natural_language_insights(\n    rolling_avg, ema, rsi, bollinger_upper, bollinger_lower,\n    price_change, volume_change, dow_rolling_avg, market_open_duration, dow_price_change, dow_volume_change, \n    daily_high, daily_low, buying_momentum, selling_momentum, timestamp\n):\n    prompt = f\"\"\"\n    You are a professional stock broker. Apple's stock has a 5-minute rolling average of {rolling_avg:.2f}.\n    The Exponential Moving Average (EMA) is {ema:.2f}, and the Relative Strength Index (RSI) is {rsi:.2f}.\n    The Bollinger Bands are set with an upper band of {bollinger_upper:.2f} and a lower band of {bollinger_lower:.2f}.\n    The price has changed by {price_change:.2f}, and the volume has shifted by {volume_change}.\n    The DOW price has changed by {dow_price_change:.2f}, and the volume has shifted by {dow_volume_change}.\n    Meanwhile, the Dow Jones index has a 5-minute rolling average of {dow_rolling_avg:.2f}.\n    The market has been open for {market_open_duration:.2f} minutes.\n    Today's high was {daily_high:.2f} and low was {daily_low:.2f}.\n    The buying momentum is {buying_momentum:.2f} and selling momentum is {selling_momentum:.2f}.\n    Based on this data, provide insights into the current stock trend and the general market sentiment.\n    The insights should not be longer than 100 words and should not have an introduction.\n    \"\"\"\n    response = ollama.chat(\n        model=\"llama3\",\n        messages=&#91;{\"role\": \"user\", \"content\": prompt}]\n    )\n    response_text = response&#91;'message']&#91;'content'].strip()\n    print(\"Natural Language Insight:\", response_text)<\/code><\/code><\/pre>\n\n\n\n<p id=\"1967\">\u8be5\u529f\u80fd\u4f7f\u7528\u524d 5 \u5206\u949f\u7684\u6280\u672f\u6307\u6807\u548c\u8d8b\u52bf\uff0c\u4ee5\u7b80\u5355\u7684\u82f1\u8bed\u603b\u7ed3\u80a1\u7968\u8868\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"c0b0\"><strong>\u6b65\u9aa4 6\uff1a\u8bbe\u7f6e Streamlit \u7528\u6237\u754c\u9762<\/strong><\/h3>\n\n\n\n<p id=\"52a8\">\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u7528 Streamlit \u8bbe\u7f6e\u4e00\u4e2a\u57fa\u672c\u7684\u7528\u6237\u754c\u9762\uff0c\u5b9e\u65f6\u663e\u793a\u80a1\u7968\u66f4\u65b0\u548c\u89c1\u89e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>message = st.chat_message(\"assistant\")\nmessage.write(timestamp)\nmessage.write(response_text)<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><code>streamlit run app.py<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\" id=\"7fc1\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.readmedium.com\/v2\/resize:fit:800\/0*R8YN0Od20TVNYO6e.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"b245\">\u5230\u8fd9\u91cc\uff0c\u4f60\u5c31\u62e5\u6709\u81ea\u5df1\u7684\u5b9e\u65f6\u80a1\u7968\u987e\u95ee\u4e86\uff01\u5982\u679c\u9700\u8981\u4e2d\u6587\uff0c\u4f60\u53ef\u4ee5\u5728\u524d\u9762\u5b9a\u4e49\u8f93\u51fa\u8bed\u8a00\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5978\"><strong>\u6539\u8fdb\u548c\u63d0\u5347\u7a7a\u95f4<\/strong><\/h3>\n\n\n\n<p id=\"d421\">\u8be5\u9879\u76ee\u53ea\u662f\u4e00\u4e2a\u539f\u578b\uff0c\u91cd\u70b9\u5173\u6ce8\u4e0a\u4e00\u4e2a\u4ea4\u6613\u65e5\u7684\u8d8b\u52bf\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u7eb3\u5165\u5386\u53f2\u6570\u636e\u3001\u65b0\u95fb\u6574\u5408\u6216\u65f6\u95f4\u5e8f\u5217\u795e\u7ecf\u7f51\u7edc\u7b49\u9ad8\u7ea7\u6a21\u578b\u6765\u6539\u8fdb\u5b83\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5347\u7ea7\u6784\u60f3\u4f9b\u60a8\u53c2\u8003\uff08\u81ea\u5df1\u53bb\u6298\u817e\uff09\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5386\u53f2\u6570\u636e\u96c6\u6210\uff1a<\/strong>\u76ee\u524d\uff0c\u8be5\u5e94\u7528\u7a0b\u5e8f\u53ea\u5904\u7406\u524d\u4e00\u4e2a\u4ea4\u6613\u65e5\u7684\u6570\u636e\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u6574\u5408\u6570\u5468\u6216\u6570\u6708\u7684\u6eda\u52a8\u5386\u53f2\u6570\u636e\u7a97\u53e3\u6765\u589e\u5f3a\u5176\u529f\u80fd\u3002<\/li>\n\n\n\n<li><strong>\u65b0\u95fb\u6574\u5408\uff1a<\/strong>\u80a1\u7968\u8d70\u52bf\u7ecf\u5e38\u53d7\u5230\u65b0\u95fb\u4e8b\u4ef6\u7684\u5f71\u54cd\u3002\u6dfb\u52a0\u5b9e\u65f6\u65b0\u95fb\u6e90\u53ef\u63d0\u4f9b\u66f4\u597d\u7684\u80cc\u666f\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><strong>\u9ad8\u7ea7\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\uff1a<\/strong>\u60a8\u53ef\u4ee5\u901a\u8fc7\u65f6\u95f4\u5e8f\u5217\u795e\u7ecf\u7f51\u7edc\u8fdb\u4e00\u6b65\u63d0\u9ad8\u6d1e\u5bdf\u529b\uff0c\u4ece\u800c\u83b7\u5f97\u66f4\u51c6\u786e\u7684\u8d8b\u52bf\u9884\u6d4b\u3002<\/li>\n\n\n\n<li><strong>\u81ea\u5b9a\u4e49\u8b66\u62a5\uff1a<\/strong>\u6839\u636e\u91cd\u8981\u7684\u80a1\u7968\u8d70\u52bf\u6216 RSI \u7b49\u6307\u6807\u5b9e\u65bd\u81ea\u5b9a\u4e49\u8b66\u62a5\uff0c\u53ef\u4f7f\u8fd9\u6b3e\u5e94\u7528\u7a0b\u5e8f\u5bf9\u65e5\u95f4\u4ea4\u6613\u8005\u66f4\u52a0\u5b9e\u7528\u3002<\/li>\n<\/ol>\n\n\n\n<p id=\"f797\">\u5b8c\u6574\u7684\u6e90\u4ee3\u7801\u548c Jupyter Notebook \u53ef\u5728\u6211\u7684<a href=\"https:\/\/github.com\/alexyu2013\/llama3\/tree\/main\/stock-trader\"> GitHub<\/a> \u4e2d\u83b7\u53d6\u3002\u5982\u679c\u60a8\u6709\u4f18\u5316\u63d0\u793a\u6216\u5176\u4ed6\u6539\u8fdb\u610f\u89c1\uff0c\u8bf7\u968f\u65f6\u8054\u7cfb\u6211\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/alexyu2013\/llama3\/tree\/main\/stock-trader\">https:\/\/github.com\/alexyu2013\/llama3\/tree\/main\/stock-trader<\/a><\/p>\n\n\n\n<p><strong>\u611f\u8c22\u60a8\u9605\u8bfb\u5230\u6700\u540e\uff0c\u5e0c\u671b\u672c\u6587\u80fd\u7ed9\u60a8\u5e26\u6765\u65b0\u7684\u6536\u83b7\u3002\u5982\u679c\u5bf9\u6587\u4e2d\u7684\u5185\u5bb9\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u8bf7\u7ed9\u6211\u7559\u8a00\uff0c\u5fc5\u590d\u3002<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u672c<\/mark><\/strong><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u6587\u5185\u5bb9\u4ec5\u4ec5\u662f\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u5e76\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/mark><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u8f6c\u53d1\u8bf7\u6ce8\u660e\u539f\u4f5c\u8005\u548c\u51fa\u5904\u3002<\/mark><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.laoyulaoyu.com\/index.php\/2024\/11\/15\/ollama-%e5%87%ba%e9%a9%ac%ef%bc%8c%e4%b8%ba%e4%bd%a0%e5%88%9b%e5%bb%ba%e5%ae%9e%e6%97%b6-ai-%e8%82%a1%e7%a5%a8%e9%a1%be%e9%97%ae\/\">Continue reading<span class=\"screen-reader-text\">Ollama \u51fa\u9a6c\uff0c\u4e3a\u4f60\u521b\u5efa\u5b9e\u65f6 AI \u80a1\u7968\u987e\u95ee<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[4,5],"class_list":{"0":"post-1629","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-aiinvest","7":"tag-ai","9":"entry"},"_links":{"self":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1629"}],"version-history":[{"count":3,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1629\/revisions"}],"predecessor-version":[{"id":1632,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1629\/revisions\/1632"}],"wp:attachment":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}