Skip to main content
이 노트북은 Symbl.ai의 채팅 모델인 Nebula를 시작하는 방법을 다룹니다.

통합 세부 정보

자세한 문서는 API reference를 참조하세요.

모델 기능: TODO

설정

자격 증명

시작하려면 Nebula API key를 요청하고 NEBULA_API_KEY 환경 변수를 설정하세요:
import getpass
import os

os.environ["NEBULA_API_KEY"] = getpass.getpass()

설치

통합은 langchain-community 패키지에 설정되어 있습니다.

인스턴스화

from langchain_community.chat_models.symblai_nebula import ChatNebula
from langchain.messages import AIMessage, HumanMessage, SystemMessage
chat = ChatNebula(max_tokens=1024, temperature=0.5)

호출

messages = [
    SystemMessage(
        content="You are a helpful assistant that answers general knowledge questions."
    ),
    HumanMessage(content="What is the capital of France?"),
]
chat.invoke(messages)
AIMessage(content=[{'role': 'human', 'text': 'What is the capital of France?'}, {'role': 'assistant', 'text': 'The capital of France is Paris.'}])

비동기

await chat.ainvoke(messages)
AIMessage(content=[{'role': 'human', 'text': 'What is the capital of France?'}, {'role': 'assistant', 'text': 'The capital of France is Paris.'}])

스트리밍

for chunk in chat.stream(messages):
    print(chunk.content, end="", flush=True)
 The capital of France is Paris.

배치

chat.batch([messages])
[AIMessage(content=[{'role': 'human', 'text': 'What is the capital of France?'}, {'role': 'assistant', 'text': 'The capital of France is Paris.'}])]

체이닝

from langchain_core.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_template("Tell me a joke about {topic}")
chain = prompt | chat
chain.invoke({"topic": "cows"})
AIMessage(content=[{'role': 'human', 'text': 'Tell me a joke about cows'}, {'role': 'assistant', 'text': "Sure, here's a joke about cows:\n\nWhy did the cow cross the road?\n\nTo get to the udder side!"}])

API 참조

자세한 내용은 API reference를 확인하세요.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I