Select Page

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613
如何使用 Groq API 快速測試和部署大型語言模型

如何使用 Groq API 快速測試和部署大型語言模型


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Groq 是一家擁有高效能硬體運算的公司,提供大型語言模型(LLM)的推理運算提供加速解決方案,他們的硬體相較於傳統 GPU,更加快速,並且支援多種主流開源模型,包括 Llama 3、Mistral 等。

Groq API 的主要特色

1. 提供 Playground 供快速測試

為了讓開發者能夠直觀地體驗和測試模型,Groq 提供了線上 Playground。​使用者可以在此平台上直接輸入指令或問題,立即獲得模型的回應,無需進行繁瑣的設定或部署。​

2. 詳細的 API 文件

Groq 提供了詳細且易於理解的 API 文件,涵蓋從基本使用到進階功能的各種說明,協助開發者快速上手並整合到自己的專案中。​

3. 高速反應能力

得益於 Groq 的硬體架構,API 的反應速度極快,能夠即時處理大型語言模型的推理需求,提升使用者體驗。​

如何開始使用 Groq API

  1. 註冊並獲取 API 金鑰
    • 前往 Groq 官方網站,點擊「Login」或「Get API Key」,按照提示完成註冊並獲取 API 金鑰。​
  2. 選擇開發環境並調用 API
    • Python:​使用 OpenAI 兼容的客戶端調用 Groq 提供的模型。
import openai

openai.api_key = 'YOUR_GROQ_API_KEY'
openai.api_base = 'https://api.groq.com/openai/v1'

response = openai.ChatCompletion.create(
    model="groq/llama3-70b-8192",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "請介紹一下 Groq API 的特色。"}
    ]
)

print(response.choices[0].message['content'])

其他語言:​Groq 的 API 兼容 OpenAI 的接口,因此在其他編程語言中,只需將 API 基礎 URL 更改為 https://api.groq.com/openai/v1,並使用您的 Groq API 金鑰即可。

參考資料


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613
如何在 NVIDIA 平台上免費使用 DeepSeek R1 模型

如何在 NVIDIA 平台上免費使用 DeepSeek R1 模型


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

DeepSeek R1 模型已經在 NVIDIA 平台上線,這是一個擁有 6710 億參數的開放式專家混合模型(MoE),專為解決需要高級 AI 推理的問題而設計的,但就是官方API不穩定,只能到處尋找替代的解決方案。​

DeepSeek R1 的主要特點

  1. API 友好性:​DeepSeek R1 提供了多種 API 接口,支持 Python、LangChain、Node.js 和 Shell 等,方便開發者根據需求選擇合適的開發環境。​
  2. 免費使用額度:​NVIDIA 為個人和企業用戶提供了免費的使用額度。個人用戶可獲得 1000 點額度,企業用戶則可獲得 4000 點額度,讓更多人能夠體驗和使用該模型。 ​

如何開始使用 DeepSeek R1

以下是使用 DeepSeek R1 的基本步驟:

  1. 註冊並獲取 API 密鑰
    • 前往 NVIDIA NIM 平台的 DeepSeek R1 頁面:
    • 點擊右上角的「Login」或「Get API Key」,按照提示完成註冊並獲取 API 密鑰。​
  2. 選擇開發環境並調用 API
    • Python:​使用 OpenAI 兼容的客戶端調用 DeepSeek R1。​ python複製編輯
    • LangChain:​可將 DeepSeek R1 集成到 LangChain 框架中,實現更複雜的語言處理任務。​
    • Node.jsShell:​NVIDIA 提供了相應的 SDK 和示例代碼,開發者可根據官方文檔進行集成。

用 python 來做示範

from openai import OpenAI

client = OpenAI(
  base_url = "https://integrate.api.nvidia.com/v1",
  api_key = "YOUR_API_KEY"
)

completion = client.chat.completions.create(
  model="deepseek-ai/deepseek-r1",
  messages=[{"role":"user","content":"你的問題內容"}],
  temperature=0.6,
  top_p=0.7,
  max_tokens=4096,
  stream=True
)

for chunk in completion:
  if chunk.choices[0].delta.content is not None:
    print(chunk.choices[0].delta.content, end="")

注意事項

  • 使用額度:​請留意您的免費使用額度,合理規劃 API 調用次數。

參考資料

https://build.nvidia.com/deepseek-ai/deepseek-r1


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613
OpenRouter:輕鬆接入多種大型語言模型的統一平台

OpenRouter:輕鬆接入多種大型語言模型的統一平台


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

OpenRouter 是一個統一的大型語言模型(LLM)API 服務平台,可以讓使用者透過單一介面訪問多種大型語言模型。

主要特點:

  • 多模型支援: OpenRouter 集成了多種預訓練模型,如 GPT-4、Gemini、Claude、DALL-E 等,按需求選擇適合的模型。
  • 易於集成: 提供統一的 API 介面,方便與現有系統整合,無需自行部署和維護模型。
  • 成本效益: 透過 API 調用,使用者無需購買昂貴的 GPU 伺服器,降低了硬體成本。

使用方法:

  1. 註冊帳號: 使用 Google 帳號即可快速註冊 OpenRouter。
  2. 選擇模型: 在平台上瀏覽並選擇適合的模型,部分模型提供免費使用。
  3. 調用 API: 使用統一的 API 介面,將選定的模型整合到您的應用中。

Cline 整合

OpenRouter 與 Cline 的整合為開發者提供了強大的 AI 編程體驗,Cline 是一款集成於 VSCode 的 AI 編程助手,支援多種大型語言模型(LLM),如 OpenAI、Anthropic、Mistral 等,透過 OpenRouter,Cline 能夠統一調用這些模型,簡化了不同模型之間的切換和管理,使用者只需在 Cline 的設定中選擇 OpenRouter 作為 API 提供者,並輸入相應的 API 金鑰,即可開始使用多種模型進行開發。這種整合不僅提升了開發效率,還降低了使用多模型的技術門檻。

DeepSeek R1

OpenRouter 現在也支援 DeepSeek R1 模型,DeepSeek R1 是一款高性能的開源 AI 推理模型,具有強大的數學、編程和自然語言推理能力。透過 OpenRouter,開發者可以在 Cline 中輕鬆調用 DeepSeek R1 模型,享受其強大的推理能力。這進一步豐富了開發者的工具選擇,讓他們能夠根據項目需求選擇最適合的模型。


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613
用AI操作電腦的這一天來了,Ahthropic Computer Use

用AI操作電腦的這一天來了,Ahthropic Computer Use


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

終於來到電影中的AI操作電腦的情節了,動動嘴巴就可以控制電腦,AI 透過 LLM 模型,知道你的意圖,在看你的電腦畫面,去決定要點選甚麼樣的位置,或是輸入甚麼樣的資訊,原來可以這麼簡單就實現用嘴巴操作電腦

準備 API Key

請先到這邊,https://www.anthropic.com/api,取得 API Key,等等 docker 建立的時候會用到

Docker 安裝 Ahthropic computer use

Linux / Mac

export ANTHROPIC_API_KEY=%your_api_key%
docker run \
    -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
    -v $HOME/.anthropic:/home/computeruse/.anthropic \
    -p 5900:5900 \
    -p 8501:8501 \
    -p 6080:6080 \
    -p 8080:8080 \
    -it ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest

Windows

export ANTHROPIC_API_KEY=%your_api_key%

docker run `
    -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY `
    -v $HOME/.anthropic:/home/computeruse/.anthropic `
    -p 5900:5900 `
    -p 8501:8501 `
    -p 6080:6080 `
    -p 8080:8080 `
    -it ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613
開發 ChatGPT 的兩種方法

開發 ChatGPT 的兩種方法


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in C:\inetpub\raintips\wp-content\themes\Divi\core\functions.php on line 1613

ChatGPT 一開始出來的時候還沒有開放 API 的時候,就有很多人用 Session key 的方法去使用他的服務,到現在雖然說用官方的 OpenAPI 已經很強大了,但缺點是 ChatGPT 永遠比較新,像是剛出來 ChatGPT 4 的時候,就沒有 API 可以用,都要等好幾個月,這時候只能使用 Session key 的方法去存取服務,這個方法可以採用 revChatGPT

revChatGPT 的三種安裝方法

原始碼下載:

https://github.com/acheong08/ChatGPT

Pip 安裝

https://pypi.org/project/revChatGPT/

只要打下面的指令就可以安裝

python -m pip install --upgrade revChatGPT

revChatGPT 的使用方法

免費使用要用 V1 ,免費版本會有些限制,目前的限制如下

  • Proxy server: 5 requests / 10 seconds
  • OpenAI: 50 requests / hour for each account

採用登入方法,要去 config.json 中填入你的帳號和密碼

{
  "email": "email",
  "password": "your password"
}

採用 Session Key 的方法,要去你的瀏覽器中,找到你的 Key 並且回填,但這種方法,一旦你登出後就要重新來過,只有自己一個人使用的時候可以用,比較不推薦,使用方法,先點下面的連結

https://chat.openai.com/api/auth/session

找到 accessToken 後面的文字,複製後取代 <access_token> 即可

{
  "access_token": "<access_token>"
}

設定完成後可以建立一個 Python 檔案,測試一下

from revChatGPT.V1 import Chatbot
chatbot = Chatbot(config={
  "access_token": "<your access_token>"
})
print("Chatbot: ")
prev_text = ""
for data in chatbot.ask(
    "請給我10個拯救地球的好主意",
):
    message = data["message"][len(prev_text) :]
    print(message, end="", flush=True)
    prev_text = data["message"]
print()

OpenAI 官方 Python API

這邊網路教學很多,而且常常在改,我就放一個教學,可以直接去看一下