跳到主要内容
Upstage 是一家领先的人工智能 (AI) 公司,专门提供超越人类水平性能的 LLM 组件。 Solar Pro 是一款企业级 LLM,针对单 GPU 部署进行了优化,擅长遵循指令和处理 HTML 和 Markdown 等结构化格式。它支持英语、韩语和日语,具有顶级的多语言性能,并在金融、医疗保健和法律领域提供专业知识。
除了 Solar,Upstage 还提供用于实际 RAG(检索增强生成)的功能,例如文档解析事实核查

Upstage LangChain 集成

API描述导入使用示例
聊天使用 Solar Chat 构建助手from langchain_upstage import ChatUpstage前往
文本嵌入将字符串嵌入到向量中from langchain_upstage import UpstageEmbeddings前往
事实核查验证助手的回复的事实准确性from langchain_upstage import UpstageGroundednessCheck前往
文档解析序列化包含表格和图像的文档from langchain_upstage import UpstageDocumentParseLoader前往
有关模型和功能的更多详细信息,请参阅文档

安装和设置

安装 langchain-upstage
pip install -qU langchain-core langchain-upstage
获取API 密钥并设置环境变量 UPSTAGE_API_KEY
import os

os.environ["UPSTAGE_API_KEY"] = "YOUR_API_KEY"

聊天模型

Solar LLM

查看使用示例
from langchain_upstage import ChatUpstage

chat = ChatUpstage()
response = chat.invoke("Hello, how are you?")
print(response)

嵌入模型

查看使用示例
from langchain_upstage import UpstageEmbeddings

embeddings = UpstageEmbeddings(model="solar-embedding-1-large")
doc_result = embeddings.embed_documents(
    ["Sung is a professor.", "This is another document"]
)
print(doc_result)

query_result = embeddings.embed_query("What does Sung do?")
print(query_result)

文档加载器

文档解析

查看使用示例
from langchain_upstage import UpstageDocumentParseLoader

file_path = "/PATH/TO/YOUR/FILE.pdf"
layzer = UpstageDocumentParseLoader(file_path, split="page")

# For improved memory efficiency, consider using the lazy_load method to load documents page by page.
docs = layzer.load()  # or layzer.lazy_load()

for doc in docs[:3]:
    print(doc)

工具

事实核查

查看使用示例
from langchain_upstage import UpstageGroundednessCheck

groundedness_check = UpstageGroundednessCheck()

request_input = {
    "context": "Mauna Kea is an inactive volcano on the island of Hawaii. Its peak is 4,207.3 m above sea level, making it the highest point in Hawaii and second-highest peak of an island on Earth.",
    "answer": "Mauna Kea is 5,207.3 meters tall.",
}
response = groundedness_check.invoke(request_input)
print(response)

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.