Socket
Socket
Sign inDemoInstall

@langchain/openai

Package Overview
Dependencies
Maintainers
4
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/openai - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6-rc.0

3

dist/embeddings.d.ts

@@ -22,3 +22,4 @@ import { type ClientOptions } from "openai";

* Whether to strip new lines from the input text. This is recommended by
* OpenAI, but may not be suitable for all use cases.
* OpenAI for older models, but may not be suitable for all use cases.
* See: https://github.com/openai/openai-python/issues/418#issuecomment-1525939500
*/

@@ -25,0 +26,0 @@ stripNewLines?: boolean;

@@ -38,2 +38,3 @@ import { OpenAI as OpenAIClient } from "openai";

});
// TODO: Update to `false` on next minor release (see: https://github.com/langchain-ai/langchainjs/pull/3612)
Object.defineProperty(this, "stripNewLines", {

@@ -40,0 +41,0 @@ enumerable: true,

{
"name": "@langchain/openai",
"version": "0.0.5",
"version": "0.0.6-rc.0",
"description": "OpenAI integrations for LangChain.js",

@@ -16,3 +16,4 @@ "type": "module",

"scripts": {
"build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
"build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
"build:deps": "yarn run turbo:command build --filter=@langchain/core",
"build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/",

@@ -29,5 +30,5 @@ "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rimraf dist-cjs",

"release": "release-it --only-version --config .release-it.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
"test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
"format": "prettier --write \"src\"",

@@ -39,3 +40,3 @@ "format:check": "prettier --check \"src\""

"dependencies": {
"@langchain/core": "~0.1.0",
"@langchain/core": "~0.1.2-rc.0",
"js-tiktoken": "^1.0.7",

@@ -42,0 +43,0 @@ "openai": "^4.19.0",

@@ -1,1 +0,100 @@

# langchain-openai
# @langchain/openai
This package contains the LangChainJS integrations for OpenAI through their SDK.
## Installation
```bash npm2yarn
npm install @langchain/openai
```
## Chat Models
This package contains the `ChatOpenAI` class, which is the recommended way to interface with the OpenAI series of models.
To use, install the requirements, and configure your environment.
```bash
export OPENAI_API_KEY=your-api-key
```
Then initialize
```typescript
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
apiKey: process.env.OPENAI_API_KEY,
modelName: "gpt-4-1106-preview",
});
const response = await model.invoke(new HumanMessage("Hello world!"));
```
### Streaming
```typescript
import { ChatOpenAI } from "@langchain/openai";
const model = new ChatOpenAI({
apiKey: process.env.OPENAI_API_KEY,
modelName: "gpt-4-1106-preview",
});
const response = await model.stream(new HumanMessage("Hello world!"));
```
## Embeddings
This package also adds support for OpenAI's embeddings model.
```typescript
import { OpenAIEmbeddings } from "@langchain/openai";
const embeddings = new OpenAIEmbeddings({
apiKey: process.env.OPENAI_API_KEY,
});
const res = await embeddings.embedQuery("Hello world");
```
## Development
To develop the OpenAI package, you'll need to follow these instructions:
### Install dependencies
```bash
yarn install
```
### Build the package
```bash
yarn build
```
Or from the repo root:
```bash
yarn build --filter=@langchain/openai
```
### Run tests
Test files should live within a `tests/` file in the `src/` folder. Unit tests should end in `.test.ts` and integration tests should
end in `.int.test.ts`:
```bash
$ yarn test
$ yarn test:int
```
### Lint & Format
Run the linter & formatter to ensure your code is up to standard:
```bash
yarn lint && yarn format
```
### Adding new entrypoints
If you add a new file to be exported, either import & re-export from `src/index.ts`, or add it to `scripts/create-entrypoints.js` and run `yarn build` to generate the new entrypoint.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc