Use this Python code snippet (example using SeaLLM-7B-v2.5 model):
from langchain_community.chat_models import ChatOpenAI
from langchain.schema import HumanMessage
FLOAT16_BASE_URL = "https://api.float16.cloud/v1/"
FLOAT16_API_KEY = "<your API key>"
chat = ChatOpenAI(
model="seallm-7b-v3",
api_key=FLOAT16_API_KEY,
base_url=FLOAT16_BASE_URL,
streaming=True,
)
# Simple invocation:
print(chat.invoke([HumanMessage(content="Hello")]))
# Streaming invocation:
for chunk in chat.stream("Write me a blog about how to start to raise cats"):
print(chunk.content, end="", flush=True)
For more information on the LangChain library, visit the LangChain docs.