Is there any option to use Azure open ai chat completion use your own data(data source) with langchain? #2863
Replies: 1 comment 4 replies
-
🤖 Hello, Yes, you can use your own data sources with the Azure OpenAI chat completion model in LangChain. You can pass tools or functions to the model. These tools or functions can be used to fetch data from your own data sources. Here is an example of how you can do this: const modelForFunctionCalling = new ChatOpenAI({
modelName: "gpt-4",
temperature: 0,
});
await modelForFunctionCalling.predictMessages(
[new HumanMessage("What is the weather in New York?")],
{
functions: [
{
name: "get_current_weather",
description: "Get the current weather in a given location",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and state, e.g. San Francisco, CA",
},
unit: { type: "string", enum: ["celsius", "fahrenheit"] },
},
required: ["location"],
},
},
],
// You can set the `function_call` arg to force the model to use a function
function_call: {
name: "get_current_weather",
},
}
); In this example, a function named You can find more examples in the examples/src/models/chat/integration_openai.ts file in the LangChainJS repository. Also, the LangChainJS framework does support integration with Azure OpenAI chat completion model. You can create a new instance of the OpenAI chat model and specify the model version and temperature as shown in the code snippet below: import { ChatOpenAI } from "langchain/chat_models/openai";
const model = new ChatOpenAI({
modelName: "gpt-4-0613",
temperature: 0,
}); However, the context shared does not provide information about how to authenticate requests to the OpenAI API. You might need to refer to the Azure OpenAI documentation for that. I hope this helps! If you have any other questions, feel free to ask. Best, Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have started using langchain with azure chat completion model hosted.I also needed to pass data sources to the chat completion model as in azure playground/ REST api . IS there any option to do so?
Beta Was this translation helpful? Give feedback.
All reactions