Replies: 1 comment 2 replies
-
To convert your LangChain Python code to LangChain JS and resolve the 404 error, you need to ensure that the configuration and endpoint structure are correctly set up in your JavaScript code. Here is how you can do it: Python Codefrom langchain_core.messages import HumanMessage, SystemMessage
from langchain_openai import ChatOpenAI
chat = ChatOpenAI(
default_headers={"model-name": "Llama-3-8B-cyber-security-task"},
openai_api_base="https://xxxxxxxxxx.com/openai/deployments/llama-small-deploy",
openai_api_key=""
)
messages = [
SystemMessage(content="You are a private assistant"),
HumanMessage(content="hello"),
]
response = chat.invoke(messages)
print(response) JavaScript Codeimport { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
temperature: 0.01,
apiKey: "",
basePath: "https://xxxxxxxxxx.com/openai/deployments/llama-small-deploy",
headers: {
"model-name": "Llama-3-8B-cyber-security-task"
},
});
const res = await model.invoke([
["system", "You are a private assistant"],
["human", "hello"],
]);
console.log(res); Key Points:
This should help you reproduce the same functionality in LangChain JS and resolve the 404 error [1]. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checked other resources
Commit to Help
Example Code
Description
Hi I am trying to use Langchain Js, Here is code I am using in Python, I am using ChatOpenAI module to connect to a LLM host by us. But turn into Langchian Js, I am not sure what can reproduce the same .
I have try and it return error 401
would you mind to give me some opinion on how to do this. Thank you very much
System Info
Beta Was this translation helpful? Give feedback.
All reactions