如何
1. 获取链接:访问https://shaleprotocol.com,在Discord上通过”Shale bot”生成API密钥(无需信用卡,无免费试用,为永久免费套餐,每日每API密钥上限1K次请求)
2. 使用https://shale.live/v1作为OpenAI API的即插即用替代方案
示例:官方原文:src/oss/python/integrations/providers/shaleprotocol.mdx · 非官方翻译,译文由 AI 生成,以英文原文为准。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
使用 LangChain Python 集成 Shale 协议。
from langchain_openai import OpenAI
from langchain_core.prompts import PromptTemplate
from langchain_core.output_parsers import StrOutputParser
import os
os.environ['OPENAI_API_BASE'] = "https://shale.live/v1"
os.environ['OPENAI_API_KEY'] = "ENTER YOUR API KEY"
llm = OpenAI()
template = """Question: {question}
# Answer: Let's think step by step."""
prompt = PromptTemplate.from_template(template)
llm_chain = prompt | llm | StrOutputParser()
question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"
llm_chain.invoke(question)
官方原文:src/oss/python/integrations/providers/shaleprotocol.mdx · 非官方翻译,译文由 AI 生成,以英文原文为准。