{"id":53740,"date":"2025-02-16T13:21:43","date_gmt":"2025-02-16T05:21:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53740\/"},"modified":"2025-02-16T13:21:43","modified_gmt":"2025-02-16T05:21:43","slug":"phidata%e4%bb%a3%e7%90%86%e5%bc%80%e5%8f%91%e7%ae%80%e6%98%8e%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53740\/","title":{"rendered":"Phidata\u4ee3\u7406\u5f00\u53d1\u7b80\u660e\u6559\u7a0b"},"content":{"rendered":"<p>\u4f60\u770b\uff0c\u5373\u4f7f\u662f\u5f3a\u5927\u7684 LLM \u4e5f\u5e76\u4e0d\u603b\u662f\u65e0\u6240\u4e0d\u77e5\uff08\u5c3d\u7ba1\u4ed6\u4eec\u53ef\u80fd\u8868\u73b0\u5f97\u50cf\u4e2a\u4e07\u4e8b\u901a\uff01\uff09\u3002\u5c31\u50cf\u6240\u6709\u4f1f\u5927\u7684\u4e8b\u7269\u4e00\u6837\uff0c\u4ed6\u4eec\u6709\u65f6\u4e5f\u9700\u8981\u5916\u754c\u7684\u4e00\u70b9\u5e2e\u52a9\u2014\u2014\u5728\u63a8\u7406\u3001\u6570\u5b66\u3001\u7f16\u7801\u6216\u4efb\u4f55\u590d\u6742\u4efb\u52a1\u4e2d\u9700\u8981\u989d\u5916\u7684\u5e2e\u52a9\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u201c\u7cbe\u5fc3\u8bbe\u8ba1\u7684\u6587\u5b57\u201d\u3002\u8fd9\u5c31\u662f\u4ee3\u7406\u53d1\u6325\u4f5c\u7528\u7684\u5730\u65b9\u3002<\/p>\n<p>\u6709\u5f88\u591a\u5de5\u5177\u53ef\u4ee5\u6784\u5efa LLM \u4ee3\u7406\uff0c\u4f46\u5e76\u975e\u6240\u6709\u5de5\u5177\u90fd\u6613\u4e8e\u4f7f\u7528\u3002\u4eca\u5929\uff0c\u6211\u4eec\u5c06\u67e5\u770b\u4e00\u4e2a\u7b80\u5355\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6 Phidata\uff0c\u770b\u770b\u5b83\u5982\u4f55\u8ba9\u4f7f\u7528 LLM \u4ee3\u7406\u53d8\u5f97\u8f7b\u800c\u6613\u4e3e\uff01<\/p>\n<h2>1\u3001Web\u4ee3\u7406\uff1a\u901a\u5411\u5916\u90e8\u4e16\u754c\u7684\u7a97\u53e3<\/h2>\n<p>LLM \u901a\u5e38\u65e0\u6cd5\u8bbf\u95ee\u4e92\u8054\u7f51\uff0c\u56e0\u6b64\u8ba9\u4ed6\u4eec\u4f53\u9a8c\u4e00\u4e0b\u5916\u90e8\u4e16\u754c\u4f1a\u7acb\u5373\u8ba9\u4ed6\u4eec\u4e0e\u65f6\u4ff1\u8fdb\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u8ba9\u6211\u4eec\u5728 Python \u4e2d\u8bbe\u7f6e\u6211\u4eec\u6700\u559c\u6b22\u7684\u4e13\u6709 LLM\uff1a<\/p>\n<pre><code>from openai import OpenAI\nimport os\nos.environ[\"OPENAI_API_KEY\"] = \"get-your-own-api-key\"\n\nprompt = \"Is there any plane crash in South Korea recently?\"\n\nclient = OpenAI()\n\nchat_completion = client.chat.completions.create(\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": prompt,\n        }\n    ],\n    model=\"gpt-4o\",\n)\n\n## Let's print the output:\nchat_completion.choices[0].message.content<\/code><\/pre>\n<p>GPT 4o \u6ca1\u6709 2024 \u5e74 5 \u6708\u4e4b\u540e\u7684\u4efb\u4f55\u4fe1\u606f\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5f97\u5230\u4e86\u9884\u671f\u7684\u7ed3\u679c\uff1a<\/p>\n<blockquote><p>\n  \u5f88\u62b1\u6b49\uff0c\u6211\u65e0\u6cd5\u63d0\u4f9b\u6709\u5173\u6700\u8fd1\u4e8b\u4ef6\u6216\u98de\u673a\u5931\u4e8b\u7684\u5b9e\u65f6\u4fe1\u606f\u3002\u4e3a\u4e86\u627e\u5230\u6700\u65b0\u7684\u4fe1\u606f\uff0c\u6211\u5efa\u8bae\u67e5\u770b\u53ef\u9760\u7684\u65b0\u95fb\u6765\u6e90\u6216\u5b98\u65b9\u822a\u7a7a\u5f53\u5c40\u4ee5\u83b7\u53d6\u6700\u65b0\u66f4\u65b0\u3002\n<\/p><\/blockquote>\n<p>\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u4f7f\u7528 phidata \u6784\u5efa\u6211\u4eec\u7684 Web \u4ee3\u7406\u3002<\/p>\n<pre><code>web_agent = Agent(\n    name=\"Web Agent\",\n    model=OpenAIChat(id=\"gpt-4o\"),\n    tools=[DuckDuckGo()],\n    instructions=[\"Always include sources\"],\n    show_tool_calls=True,\n    markdown=True,\n)\n\nweb_agent.print_response(\"Is there any plane crash in South Korea recently?\", stream=True)<\/code><\/pre>\n<p>\u7b54\u5bf9\u4e86\uff01\u5b83\u4f7f\u7528 Duckduckgo \u641c\u7d22\u4e92\u8054\u7f51\u5e76\u627e\u5230\u4e86\u6700\u65b0\u4fe1\u606f\u3002\u6839\u636e\u6211\u7684\u7ecf\u9a8c\uff0c\u8fd9\u662f\u5de5\u5177\u6700\u91cd\u8981\u7684\u5e94\u7528\u3002<\/p>\n<h2>2\u3001\u8d22\u52a1\u4ee3\u7406\uff1a\u4f60\u81ea\u5df1\u7684\u8d22\u52a1\u987e\u95ee<\/h2>\n<p>\u6709\u4e00\u4ef6\u4e8b\u4f60\u7edd\u5bf9\u4e0d\u80fd\u4f9d\u8d56 LLM \u73b0\u6709\u7684\u77e5\u8bc6\u5e93\uff0c\u90a3\u5c31\u662f\u8d22\u52a1\u4fe1\u606f\u3002\u80a1\u7968\u4ef7\u683c\u65f6\u5e38\u53d1\u751f\u53d8\u5316\uff0c\u8981\u638c\u63e1\u6700\u65b0\u60c5\u51b5\uff0c\u4f60\u9700\u8981\u6700\u65b0\u7684\u6570\u636e\u3002\u8fd9\u5c31\u662f Phidata \u4ecb\u5165\u7684\u5730\u65b9\u2014\u2014\u5b83\u4f7f\u7528 Yahoo Finance \u83b7\u53d6\u6700\u65b0\u7684\u8d22\u52a1\u4fe1\u606f\uff0c\u5305\u62ec\u80a1\u7968\u66f4\u65b0\uff0c\u56e0\u6b64\u4f60\u59cb\u7ec8\u4e86\u89e3\u6700\u65b0\u60c5\u51b5\u3002<\/p>\n<pre><code>from phi.tools.yfinance import YFinanceTools\n\nfinance_agent = Agent(\n    name=\"Finance Agent\",\n    role=\"Financial Expert who can analyze stock price\",\n    model=OpenAIChat(id=\"gpt-4o\"),\n    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],\n    instructions=[\"Use tables to display data\"],\n    show_tool_calls=True,\n    markdown=True,\n)\n\nfinance_agent.print_response(\"Based on current stock price, should I buy, hold or sell tesla stock?\", stream=True)<\/code><\/pre>\n<p>\u8fd9\u5c31\u662f\u6211\u4eec\u6240\u5f97\u5230\u7684\uff1a<\/p>\n<pre><code>Running:                                                                                                        \u2503\n\u2503                                                                                                                 \u2503\n\u2503  \u2022 get_current_stock_price(symbol=TSLA)                                                                         \u2503\n\u2503  \u2022 get_analyst_recommendations(symbol=TSLA)                                                                     \u2503\n\u2503  \u2022 get_company_info(symbol=TSLA)                                                                                \u2503\n\u2503                                                                                                                 \u2503\n\u2503 Here's an analysis of Tesla's current stock status and recommendations:                                         \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                               Current Stock Price                                               \u2503\n\u2503                                                                                                                 \u2503\n\u2503  \u2022 Tesla Inc. (TSLA): $431.66 USD                                                                               \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                Company Overview                                                 \u2503\n\u2503                                                                                                                 \u2503\n\u2503  \u2022 Market Capitalization: $1.39 Trillion USD                                                                    \u2503\n\u2503  \u2022 Sector: Consumer Cyclical                                                                                    \u2503\n\u2503  \u2022 Industry: Auto Manufacturers                                                                                 \u2503\n\u2503  \u2022 EPS (Earnings Per Share): $3.67                                                                              \u2503\n\u2503  \u2022 P\/E Ratio: 117.62                                                                                            \u2503\n\u2503  \u2022 52-Week Range: $138.8 - $488.54 USD                                                                          \u2503\n\u2503  \u2022 Average Prices:                                                                                              \u2503\n\u2503     \u2022 50 Day: $338.59 USD                                                                                       \u2503\n\u2503     \u2022 200 Day: $236.36 USD                                                                                      \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                             Analyst Recommendations                                             \u2503\n\u2503                                                                                                                 \u2503\n\u2503 The table below summarizes recent analyst recommendations for Tesla:                                            \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                                                                                 \u2503\n\u2503   Period         Strong Buy   Buy   Hold   Sell   Strong Sell                                                   \u2503\n\u2503  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501                                                  \u2503\n\u2503   Current        6            13    15     8      5                                                             \u2503\n\u2503   1 Month Ago    5            13    17     8      5                                                             \u2503\n\u2503   2 Months Ago   6            12    19     7      4                                                             \u2503\n\u2503   3 Months Ago   5            13    18     7      4                                                             \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                   Financials                                                    \u2503\n\u2503                                                                                                                 \u2503\n\u2503  \u2022 Total Cash: $33.65 Billion USD                                                                               \u2503\n\u2503  \u2022 Free Cash Flow: $676.63 Million USD                                                                          \u2503\n\u2503  \u2022 Operating Cash Flow: $14.48 Billion USD                                                                      \u2503\n\u2503  \u2022 EBITDA: $13.24 Billion USD                                                                                   \u2503\n\u2503  \u2022 Revenue Growth: 7.8%                                                                                         \u2503\n\u2503  \u2022 Gross Margins: 18.23%                                                                                        \u2503\n\u2503  \u2022 EBITDA Margins: 13.63%                                                                                       \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                 Recommendation                                                  \u2503\n\u2503                                                                                                                 \u2503\n\u2503 Considering the current stock price of $431.66 USD, which is not far from the 52-week high of $488.54 USD, and  \u2503\n\u2503 the analyst recommendation breakdown with a predominant \"hold\" sentiment alongside a mix of buy and sell        \u2503\n\u2503 recommendations, it would be prudent at this moment to:                                                         \u2503\n\u2503                                                                                                                 \u2503\n\u2503  \u2022 Hold: if you are currently holding Tesla stock, monitoring market trends and waiting for clearer indicators  \u2503\n\u2503    could be beneficial.                                                                                         \u2503\n\u2503  \u2022 Buy: only if you strongly believe in Tesla's growth potential and your risk tolerance supports a high P\/E    \u2503\n\u2503    ratio stock.                                                                                                 \u2503\n\u2503  \u2022 Sell: only if you are looking to take profits at a nearing high resembling the 52-week peak, and have a low  \u2503\n\u2503    risk tolerance.                                                                                              \u2503\n\u2503                                                                                                                 \u2503\n\u2503 These recommendations are highly dependent on personal risk tolerance, investment strategy, and market          \u2503\n\u2503 conditions moving forward. Consulting with a financial advisor for personalized advice     <\/code><\/pre>\n<h2>3\u3001\u4ee3\u7406\u56e2\u961f\uff1a\u5229\u7528\u591a\u4e2a\u4ee3\u7406\u7684\u529b\u91cf<\/h2>\n<p>\u5728\u73b0\u5b9e\u751f\u6d3b\u4e2d\uff0c\u6709\u5f88\u591a\u60c5\u51b5\u9700\u8981\u591a\u4e2a\u670b\u53cb\u7684\u5e2e\u52a9\u3002\u60f3\u8c61\u4e00\u4e0b\uff0c\u4f60\u6b63\u5728\u4e3a\u5bfb\u6c42\u8d22\u52a1\u5efa\u8bae\u7684\u4eba\u5efa\u7acb\u5ba2\u6237\u670d\u52a1\u70ed\u7ebf\u3002\u7f51\u7edc\u4ee3\u7406\u53ef\u4ee5\u5e2e\u52a9\u4f60\u6536\u96c6\u4e00\u822c\u4fe1\u606f\uff0c\u800c\u8d22\u52a1\u4ee3\u7406\u53ef\u4ee5\u83b7\u53d6\u80a1\u7968\u4ef7\u683c\u3002\u4f46\u662f\uff0c\u5f53\u4f60\u9047\u5230\u9700\u8981\u7f51\u7edc\u548c\u8d22\u52a1\u4ee3\u7406\u5171\u540c\u5408\u4f5c\u7684\u7279\u5b9a\u95ee\u9898\u65f6\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f<\/p>\n<p>\u6211\u6709 10 \u4e07\u7f8e\u5143\u7684\u5b58\u6b3e\uff0c\u6211\u60f3\u5728 2025 \u5e74\u8fdb\u884c\u591a\u5143\u5316\u6295\u8d44\u3002\u6839\u636e\u8fc7\u53bb 10 \u5e74\u7684\u6570\u636e\uff0c\u5e2e\u52a9\u6211\u786e\u5b9a\u6211\u5e94\u8be5\u5728\u54ea\u91cc\u6295\u8d44<\/p>\n<pre><code>web_agent = Agent(\n    name=\"Web Agent\",\n    role=\"Search the web for stock market prices\",\n    model=OpenAIChat(id=\"gpt-4o\"),\n    tools=[DuckDuckGo()],\n    instructions=[\"Always include sources\"],\n    show_tool_calls=True,\n    markdown=True,\n)\n\n\nfinance_agent = Agent(\n    name=\"Finance Agent\",\n    role=\"Financial Expert who can analyze stock price\",\n    model=OpenAIChat(id=\"gpt-4o\"),\n    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],\n    instructions=[\"Use tables to display data\"],\n    show_tool_calls=True,\n    markdown=True,\n)\n\n\nagent_team = Agent(\n    team=[web_agent, finance_agent],\n    show_tool_calls=True,\n    markdown=True,\n)\n\nagent_team.print_response(\"I have $100k savings, and I want to invest it diversely in 2025. Based on last 10 years data, help me where I should invest exactlty\", stream=True)<\/code><\/pre>\n<p>\u8f93\u51fa\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre><code>To give you a comprehensive answer, I will:                                                                     \u2503\n\u2503                                                                                                                 \u2503\n\u2503  1 Research historical performance of various investment options over the last 10 years.                        \u2503\n\u2503  2 Provide analysis and investment recommendations based on diversification strategies.                         \u2503\n\u2503                                                                                                                 \u2503\n\u2503 Let me gather and analyze the data for you. I will consult financial data sources and come back with a          \u2503\n\u2503 comprehensive investment plan. Running:                                                                         \u2503\n\u2503                                                                                                                 \u2503\n\u2503  \u2022 transfer_task_to_web_agent(task_description=..., expected_output=A summary of historical returns for         \u2503\n\u2503    different investment types for the last 10 years., additional_information=Look for reputable financial       \u2503\n\u2503    sources and reports.)                                                                                        \u2503\n\u2503  \u2022 transfer_task_to_finance_agent(task_description=..., expected_output=..., additional_information=Consider    \u2503\n\u2503    factors like historical performance, risk, and potential growth.)                                            \u2503\n\u2503                                                                                                                 \u2503\n\u2503 Based on the analysis of historical performance data and the development of a diversified investment strategy,  \u2503\n\u2503 here's where you should consider investing your $100,000 in 2025.                                               \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                Summary of Historical Performance (Last 10 Years)                                \u2503\n\u2503                                                                                                                 \u2503\n\u2503  1 Stocks:                                                                                                      \u2503\n\u2503     \u2022 Average Annual Returns: 9-10% (S&amp;P 500)                                                                   \u2503\n\u2503     \u2022 Highlights: Robust performance, though volatile.                                                          \u2503\n\u2503  2 Bonds:                                                                                                       \u2503\n\u2503     \u2022 Average Annual Returns: 4-5%                                                                              \u2503\n\u2503     \u2022 Highlights: Stability with lower returns than stocks, affected by interest rates.                         \u2503\n\u2503  3 Real Estate:                                                                                                 \u2503\n\u2503     \u2022 Average Annual Returns: 3-4%                                                                              \u2503\n\u2503     \u2022 Highlights: Moderate returns; acts as an inflation hedge.                                                 \u2503\n\u2503  4 Commodities:                                                                                                 \u2503\n\u2503     \u2022 Variability: Performance linked to macroeconomic factors with significant volatility.                     \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                   Recommended Diversified Portfolio for 2025                                    \u2503\n\u2503                                                                                                                 \u2503\n\u2503 Here's the diversification strategy for investing $100,000 in 2025:                                             \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                                                                                 \u2503\n\u2503   Asset Type                Allocation Percentage   Notes                                                       \u2503\n\u2503  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501  \u2503\n\u2503   Stocks (Equities)         50%                     Focus on sectors like technology and green energy.          \u2503\n\u2503   Bonds (Fixed Income)      25%                     Offers stability, important for risk mitigation.            \u2503\n\u2503   Real Estate               15%                     A tangible asset and an inflation hedge.                    \u2503\n\u2503   Alternative Investments   10%                     Includes commodities and potentially cryptocurrency or      \u2503\n\u2503                                                     tech startups.                                              \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                                                                                 \u2503\n\u2503                                                   Rationale:                                                    \u2503\n\u2503                                                                                                                 \u2503\n\u2503  \u2022 Stocks provide the highest growth potential but require careful selection due to higher risk.                \u2503\n\u2503  \u2022 Bonds ensure stability and provide a steady income.                                                          \u2503\n\u2503  \u2022 Real Estate serves as a hedge against inflation, with potential for steady growth, especially in areas with  \u2503\n\u2503    population growth.                                                                                           \u2503\n\u2503  \u2022 Alternative Investments add diversification and the opportunity to capitalize on emerging and unconventional \u2503\n\u2503    markets.                                                                                                     \u2503\n\u2503                                                                                                                 \u2503\n\u2503 This strategic allocation aims to balance risk and return, leveraging the strength of different asset classes.  \u2503\n\u2503 For in-depth analysis of specific stocks or real-time market conditions, you may need to consult with further   \u2503\n\u2503 financial advisors or update the data closer to your investment date.                                           \u2503\n\u2503                                                                                                                 \u2503\n\u2503 Sources include historical financial studies and insights from Quantified Strategies, BlackRock, and industry   \u2503\n\u2503 performance reports.                                                                                            \u2503\n\u2503                       <\/code><\/pre>\n<p>\u5728\u8f93\u51fa\u4e2d\uff0c\u8bf7\u6ce8\u610f\u4ee5\u4e0b\u90e8\u5206\uff1atransfer_task_to_web_agent\u2026 \u8fc7\u53bb 10 \u5e74\u4e0d\u540c\u6295\u8d44\u7c7b\u578b\u7684\u5386\u53f2\u56de\u62a5\u6458\u8981\u2026\u2026\u548c transfer_task_to_finance_agent\u2026\u8003\u8651\u5386\u53f2\u8868\u73b0\u3001\u98ce\u9669\u548c\u6f5c\u5728\u589e\u957f\u7b49\u56e0\u7d20\u2026\u2026\u8fd9\u8868\u660e\u8be5\u7a0b\u5e8f\u5bfb\u6c42\u4e24\u4e2a\u4ee3\u7406\u6765\u83b7\u5f97\u5168\u9762\u7684\u7b54\u6848\u3002<\/p>\n<h2>4\u3001Phidata \u7684\u5176\u4ed6\u4ee3\u7406<\/h2>\n<p>\u67e5\u770b\u63d0\u4f9b\u7684\u4f17\u591a\u5de5\u5177\u3002\u8bdd\u867d\u5982\u6b64\uff0c\u5e76\u975e\u6240\u6709\u5de5\u5177\u90fd\u80fd\u5b8c\u7f8e\u8fd0\u884c\uff0c\u6709\u4e9b\u5de5\u5177\u8fd8\u4e0d\u5b8c\u5168\u53ef\u9760\u3002Phidata \u4ecd\u5728\u8fdb\u884c\u4e2d\uff0c\u4f46\u5982\u679c\u4f60\u60f3\u4ee5\u66f4\u5b9e\u9645\u7684\u65b9\u5f0f\u6784\u5efa\u5b8c\u5168\u53ef\u9760\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5e76\u4e14\u4e0d\u4f9d\u8d56\u6846\u67b6\uff0c\u8bf7\u7ee7\u7eed\u5173\u6ce8\u2014\u2014\u6211\u5f88\u5feb\u4f1a\u5206\u4eab\u4e00\u4e2a\u5173\u4e8e\u4ece\u5934\u5f00\u59cb\u521b\u5efa LLM \u4ee3\u7406\u7684\u8be6\u7ec6\u6559\u7a0b\uff01<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u770b\uff0c\u5373\u4f7f\u662f\u5f3a\u5927\u7684 LLM \u4e5f\u5e76\u4e0d\u603b\u662f\u65e0\u6240\u4e0d\u77e5\uff08\u5c3d\u7ba1\u4ed6\u4eec\u53ef\u80fd\u8868\u73b0\u5f97\u50cf\u4e2a\u4e07\u4e8b\u901a\uff01\uff09\u3002\u5c31\u50cf\u6240\u6709\u4f1f\u5927\u7684\u4e8b\u7269\u4e00\u6837\uff0c\u4ed6\u4eec\u6709\u65f6\u4e5f\u9700\u8981\u5916\u754c\u7684\u4e00\u70b9\u5e2e\u52a9\u2014\u2014\u5728\u63a8\u7406\u3001\u6570\u5b66\u3001\u7f16\u7801\u6216\u4efb\u4f55\u590d\u6742\u4efb\u52a1\u4e2d\u9700\u8981\u989d\u5916\u7684\u5e2e\u52a9\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u201c\u7cbe\u5fc3\u8bbe\u8ba1\u7684\u6587\u5b57\u201d\u3002\u8fd9\u5c31\u662f\u4ee3\u7406\u53d1\u6325\u4f5c\u7528\u7684\u5730\u65b9\u3002 \u6709\u5f88\u591a\u5de5\u5177\u53ef\u4ee5\u6784\u5efa LLM \u4ee3\u7406\uff0c\u4f46\u5e76\u975e\u6240\u6709\u5de5\u5177\u90fd\u6613\u4e8e\u4f7f\u7528\u3002\u4eca\u5929\uff0c\u6211\u4eec\u5c06\u67e5\u770b\u4e00\u4e2a\u7b80\u5355\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6 Phidata\uff0c\u770b\u770b\u5b83\u5982\u4f55\u8ba9\u4f7f\u7528 LLM \u4ee3\u7406\u53d8\u5f97\u8f7b\u800c\u6613\u4e3e\uff01 1\u3001Web\u4ee3\u7406\uff1a\u901a\u5411\u5916\u90e8\u4e16\u754c\u7684\u7a97\u53e3 LLM \u901a\u5e38\u65e0\u6cd5\u8bbf\u95ee\u4e92\u8054\u7f51\uff0c\u56e0\u6b64\u8ba9\u4ed6\u4eec\u4f53\u9a8c\u4e00\u4e0b\u5916\u90e8\u4e16\u754c\u4f1a\u7acb\u5373\u8ba9\u4ed6\u4eec\u4e0e\u65f6\u4ff1\u8fdb\u3002 \u4f8b\u5982\uff0c\u8ba9\u6211\u4eec\u5728 Python \u4e2d\u8bbe\u7f6e\u6211\u4eec\u6700\u559c\u6b22\u7684\u4e13\u6709 LLM\uff1a from openai import OpenAI import os os.environ[&#8220;OPENAI_API_KEY&#8221;] = &#8220;get-your-own-api-key&#8221; prompt = &#8220;Is there any plane crash in South Korea recently?&#8221; client = OpenAI() chat_completion = client.chat.completions.create( messages=[ { &#8220;role&#8221;: &#8220;user&#8221;, &#8220;content&#8221;: prompt, } ], model=&#8221;gpt-4o&#8221;, ) ## Let&#8217;s print [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-53740","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53740"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53740\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}