langchain-xfyun

在LangChain中流畅地使用讯飞星火大模型


License
MIT
Install
pip install langchain-xfyun==0.0.275b2

Documentation

🦜️🔗✨ LangChain-xfyun

⚡ 在LangChain中流畅地使用讯飞星火大模型 ⚡

Release Notes License: MIT Open in Dev Containers Open in GitHub Codespaces GitHub star chart Open Issues

⏩ 快速安装

pip install langchain-xfyun

🤔 这是什么?

大型语言模型(LLM)正在成为一种变革性技术,它使开发人员能够构建以前无法构建的应用程序。然而,孤立地使用这些 LLM 通常不足以创建真正强大的应用程序,只有将它们与其他计算或知识来源相结合,才能发挥真正的威力。

  • Fork from langchain

  • 添加了讯飞星火大模型的支持,让你可以在langchain中使用SparkLLM

  • [TODO] 修改langchain内置prompt以适应SparkLLM

  • 其它关于langchain的信息可以参考 LangChain's original README.md

❓ 如何使用

from langchain_xfyun.chat_models import ChatSpark
from langchain_xfyun.prompts import ChatPromptTemplate
from langchain_xfyun.chains import LLMChain

llm = ChatSpark(app_id="your_app_id", api_key="your_api_key",
                api_secret="your_api_secret")

prompt = ChatPromptTemplate.from_template(
    "我有一个生产[{product}]商品的公司,请帮我取一个最合适的公司名称。只输出答案本身"
)

chain = LLMChain(llm=llm, prompt=prompt, verbose=True)

product = "魔方"
ans = chain.run(product)
print(ans)
  • 像以前一样使用chat model,现在你可以使用ChatSpark而不是ChatOpenAI

  • 更详细的内容请参考langchain 官方文档

💁 Contributing

As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.

For detailed information on how to contribute, see here.