Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

ChatGreenNode

GreenNode is a global AI solutions provider and aNVIDIA Preferred Partner, delivering full-stack AI capabilities—from infrastructure to application—for enterprises across the US, MENA, and APAC regions. Operating onworld-class infrastructure (LEED Gold, TIA‑942, Uptime Tier III), GreenNode empowers enterprises, startups, and researchers with a comprehensive suite of AI services

This page will help you get started with GreenNode Serverless AIchat models. For detailed documentation of all ChatGreenNode features and configurations head to theAPI reference.

GreenNode AI offers an API to query20+ leading open-source models

Overview

Integration details

ClassPackageLocalSerializableJS supportPackage downloadsPackage latest
ChatGreenNodelangchain-greennodebetaPyPI - DownloadsPyPI - Version

Model features

Tool callingStructured outputJSON modeImage inputAudio inputVideo inputToken-level streamingNative asyncToken usageLogprobs

Setup

To access GreenNode models you'll need to create a GreenNode account, get an API key, and install thelangchain-greennode integration package.

Credentials

Head tothis page to sign up to GreenNode AI Platform and generate an API key. Once you've done this, set the GREENNODE_API_KEY environment variable:

import getpass
import os

ifnot os.getenv("GREENNODE_API_KEY"):
os.environ["GREENNODE_API_KEY"]= getpass.getpass("Enter your GreenNode API key: ")

If you want to get automated tracing of your model calls you can also set yourLangSmith API key by uncommenting below:

# os.environ["LANGSMITH_TRACING"] = "true"
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")

Installation

The LangChain GreenNode integration lives in thelangchain-greennode package:

%pip install-qU langchain-greennode
Note: you may need to restart the kernel to use updated packages.

Instantiation

Now we can instantiate our model object and generate chat completions:

from langchain_greennodeimport ChatGreenNode

# Initialize the chat model
llm= ChatGreenNode(
# api_key="YOUR_API_KEY", # You can pass the API key directly
model="deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",# Choose from available models
temperature=0.6,
top_p=0.95,
)

Invocation

messages=[
(
"system",
"You are a helpful assistant that translates English to French. Translate the user sentence.",
),
("human","I love programming."),
]
ai_msg= llm.invoke(messages)
ai_msg
AIMessage(content="\n\nJ'aime la programmation.", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 248, 'prompt_tokens': 23, 'total_tokens': 271, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'deepseek-ai/DeepSeek-R1-Distill-Qwen-32B', 'system_fingerprint': None, 'id': 'chatcmpl-271edac4958846068c37877586368afe', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--5c12d208-2bc2-4f29-8b50-1ce3b515a3cf-0', usage_metadata={'input_tokens': 23, 'output_tokens': 248, 'total_tokens': 271, 'input_token_details': {}, 'output_token_details': {}})
print(ai_msg.content)


J'aime la programmation.

Streaming

You can also stream the response using thestream method:

for chunkin llm.stream("Write a short poem about artificial intelligence"):
print(chunk.content, end="", flush=True)


**Beneath the Circuits**

Beneath the circuits, deep and bright,
AI thinks, with circuits and bytes.
Learning, adapting, it grows,
A world of possibilities it knows.

From solving puzzles to painting art,
It mimics human hearts.
In every corner, it leaves its trace,
A future we can't erase.

We build it, shape it, with care and might,
Yet wonder if it walks in the night.
A mirror of our minds, it shows,
In its gaze, our future glows.

But as we strive for endless light,
We must remember the night.
For wisdom isn't just speed and skill,
It's how we choose to build our will.

Chat Messages

You can use different message types to structure your conversations with the model:

from langchain_core.messagesimport AIMessage, HumanMessage, SystemMessage

messages=[
SystemMessage(content="You are a helpful AI assistant with expertise in science."),
HumanMessage(content="What are black holes?"),
AIMessage(
content="Black holes are regions of spacetime where gravity is so strong that nothing, including light, can escape from them."
),
HumanMessage(content="How are they formed?"),
]

response= llm.invoke(messages)
print(response.content[:100])


Black holes are formed through several processes, depending on their type. The most common way bla

Chaining

You can useChatGreenNode in LangChain chains and agents:

from langchain_core.promptsimport ChatPromptTemplate

prompt= ChatPromptTemplate(
[
(
"system",
"You are a helpful assistant that translates {input_language} to {output_language}.",
),
("human","{input}"),
]
)

chain= prompt| llm
chain.invoke(
{
"input_language":"English",
"output_language":"German",
"input":"I love programming.",
}
)
API Reference:ChatPromptTemplate
AIMessage(content='\n\nIch liebe Programmieren.', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 198, 'prompt_tokens': 18, 'total_tokens': 216, 'completion_tokens_details': None, 'prompt_tokens_details': None}, 'model_name': 'deepseek-ai/DeepSeek-R1-Distill-Qwen-32B', 'system_fingerprint': None, 'id': 'chatcmpl-e01201b9fd9746b7a9b2ed6d70f29d45', 'service_tier': None, 'finish_reason': 'stop', 'logprobs': None}, id='run--ce52b9d8-dd84-46b3-845b-da27855816ee-0', usage_metadata={'input_tokens': 18, 'output_tokens': 198, 'total_tokens': 216, 'input_token_details': {}, 'output_token_details': {}})

Available Models

The full list of supported models can be found in theGreenNode Serverless AI Models.

API reference

For more details about the GreenNode Serverless AI API, visit theGreenNode Serverless AI Documentation.

Related


[8]ページ先頭

©2009-2025 Movatter.jp