Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): Fix npm community install test #6900

Merged
merged 16 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const fs = require("fs");
const communityPackageJsonPath = "/app/monorepo/libs/langchain-community/package.json";
const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath));

if (currentPackageJson.devDependencies["@langchain/core"]) {
delete currentPackageJson.devDependencies["@langchain/core"];
if (currentPackageJson.devDependencies) {
delete currentPackageJson.devDependencies;
}

fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2));
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ node "update_resolutions_npm.js"

# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
npm install @langchain/core
npm install

npm install @langchain/core --production
npm install --production
13 changes: 11 additions & 2 deletions docs/core_docs/docs/integrations/llms/raycast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@ npm install @langchain/community @langchain/core
```

import CodeBlock from "@theme/CodeBlock";
import RaycastAIExample from "@examples/models/llm/raycast.ts";

<CodeBlock language="typescript">{RaycastAIExample}</CodeBlock>
```ts
import { RaycastAI } from "@langchain/community/llms/raycast";

import { Tool } from "@langchain/core/tools";

const model = new RaycastAI({
rateLimitPerMinute: 10, // It is 10 by default so you can omit this line
model: "<model_name>",
creativity: 0, // `creativity` is a term used by Raycast which is equivalent to `temperature` in some other LLMs
});
```

## Related

Expand Down
72 changes: 69 additions & 3 deletions docs/core_docs/docs/integrations/vectorstores/couchbase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,77 @@ chunk the text into 500 character chunks with no overlaps and index all these ch

After the data is indexed, we perform a simple query to find the top 4 chunks that are similar to the
query "What did president say about Ketanji Brown Jackson".
At the emd, also shows how to get similarity score
At the end, it also shows how to get similarity score

```ts
import { OpenAIEmbeddings } from "@langchain/openai";
import {
CouchbaseVectorStoreArgs,
CouchbaseVectorStore,
} from "@langchain/community/vectorstores/couchbase";
import { Cluster } from "couchbase";
import { TextLoader } from "langchain/document_loaders/fs/text";
import { CharacterTextSplitter } from "@langchain/textsplitters";

const connectionString =
process.env.COUCHBASE_DB_CONN_STR ?? "couchbase://localhost";
const databaseUsername = process.env.COUCHBASE_DB_USERNAME ?? "Administrator";
const databasePassword = process.env.COUCHBASE_DB_PASSWORD ?? "Password";

// Load documents from file
const loader = new TextLoader("./state_of_the_union.txt");
const rawDocuments = await loader.load();
const splitter = new CharacterTextSplitter({
chunkSize: 500,
chunkOverlap: 0,
});
const docs = await splitter.splitDocuments(rawDocuments);

const couchbaseClient = await Cluster.connect(connectionString, {
username: databaseUsername,
password: databasePassword,
configProfile: "wanDevelopment",
});

// Open AI API Key is required to use OpenAIEmbeddings, some other embeddings may also be used
const embeddings = new OpenAIEmbeddings({
apiKey: process.env.OPENAI_API_KEY,
});

const couchbaseConfig: CouchbaseVectorStoreArgs = {
cluster: couchbaseClient,
bucketName: "testing",
scopeName: "_default",
collectionName: "_default",
indexName: "vector-index",
textKey: "text",
embeddingKey: "embedding",
};

const store = await CouchbaseVectorStore.fromDocuments(
docs,
embeddings,
couchbaseConfig
);

import SimilaritySearch from "@examples/indexes/vector_stores/couchbase/similaritySearch.ts";
const query = "What did president say about Ketanji Brown Jackson";

<CodeBlock language="typescript">{SimilaritySearch}</CodeBlock>
const resultsSimilaritySearch = await store.similaritySearch(query);
console.log("resulting documents: ", resultsSimilaritySearch[0]);

// Similarity Search With Score
const resultsSimilaritySearchWithScore = await store.similaritySearchWithScore(
query,
1
);
console.log("resulting documents: ", resultsSimilaritySearchWithScore[0][0]);
console.log("resulting scores: ", resultsSimilaritySearchWithScore[0][1]);

const result = await store.similaritySearch(query, 1, {
fields: ["metadata.source"],
});
console.log(result[0]);
```

## Specifying Fields to Return

Expand Down
2 changes: 0 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"@planetscale/database": "^1.8.0",
"@prisma/client": "^4.11.0",
"@qdrant/js-client-rest": "^1.9.0",
"@raycast/api": "^1.55.2",
"@rockset/client": "^0.9.1",
"@supabase/supabase-js": "^2.45.0",
"@tensorflow/tfjs-backend-cpu": "^4.4.0",
Expand All @@ -80,7 +79,6 @@
"axios": "^0.26.0",
"chromadb": "^1.5.3",
"convex": "^1.3.1",
"couchbase": "^4.3.0",
"date-fns": "^3.3.1",
"duck-duck-scrape": "^2.2.5",
"exa-js": "^1.0.12",
Expand Down
67 changes: 0 additions & 67 deletions examples/src/indexes/vector_stores/couchbase/similaritySearch.ts

This file was deleted.

28 changes: 0 additions & 28 deletions examples/src/models/llm/raycast.ts

This file was deleted.

12 changes: 2 additions & 10 deletions libs/langchain-community/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"@planetscale/database": "^1.8.0",
"@premai/prem-sdk": "^0.3.25",
"@qdrant/js-client-rest": "^1.8.2",
"@raycast/api": "^1.55.2",
"@raycast/api": "^1.83.1",
"@rockset/client": "^0.9.1",
"@smithy/eventstream-codec": "^2.0.5",
"@smithy/protocol-http": "^3.0.6",
Expand Down Expand Up @@ -184,7 +184,7 @@
"mongodb": "^5.2.0",
"mysql2": "^3.9.8",
"neo4j-driver": "^5.17.0",
"node-llama-cpp": "2.7.3",
"node-llama-cpp": "^2",
"notion-to-md": "^3.1.0",
"officeparser": "^4.0.4",
"pdf-parse": "1.1.1",
Expand Down Expand Up @@ -286,7 +286,6 @@
"closevector-web": "0.1.6",
"cohere-ai": "*",
"convex": "^1.3.1",
"couchbase": "^4.3.0",
"crypto-js": "^4.2.0",
"d3-dsv": "^2.0.0",
"discord.js": "^14.14.1",
Expand All @@ -312,7 +311,6 @@
"mongodb": ">=5.2.0",
"mysql2": "^3.9.8",
"neo4j-driver": "*",
"node-llama-cpp": "*",
"notion-to-md": "^3.1.0",
"officeparser": "^4.0.4",
"pdf-parse": "1.1.1",
Expand Down Expand Up @@ -549,9 +547,6 @@
"convex": {
"optional": true
},
"couchbase": {
"optional": true
},
"crypto-js": {
"optional": true
},
Expand Down Expand Up @@ -627,9 +622,6 @@
"neo4j-driver": {
"optional": true
},
"node-llama-cpp": {
"optional": true
},
"notion-to-md": {
"optional": true
},
Expand Down
1 change: 1 addition & 0 deletions libs/langchain-community/src/chat_models/llama_cpp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import {
LlamaModel,
LlamaContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import { Cluster, QueryResult } from "couchbase";
import { Document } from "@langchain/core/documents";
import {
Expand Down
1 change: 1 addition & 0 deletions libs/langchain-community/src/embeddings/llama_cpp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import { LlamaModel, LlamaContext } from "node-llama-cpp";
import { Embeddings, type EmbeddingsParams } from "@langchain/core/embeddings";
import {
Expand Down
1 change: 1 addition & 0 deletions libs/langchain-community/src/llms/llama_cpp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import {
LlamaModel,
LlamaContext,
Expand Down
6 changes: 5 additions & 1 deletion libs/langchain-community/src/llms/raycast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export class RaycastAI extends LLM implements RaycastAIInput {
throw new Error("Raycast AI environment is not accessible.");
}

this.model = fields.model ?? "text-davinci-003";
if (fields.model === undefined) {
throw new Error(`You must provide a "model" field in your params.`);
}

this.model = fields.model;
this.creativity = fields.creativity ?? 0.5;
this.rateLimitPerMinute = fields.rateLimitPerMinute ?? 10;
}
Expand Down
1 change: 1 addition & 0 deletions libs/langchain-community/src/utils/llama_cpp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import {
LlamaModel,
LlamaContext,
Expand Down
1 change: 1 addition & 0 deletions libs/langchain-community/src/vectorstores/couchbase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable import/no-extraneous-dependencies */
import { EmbeddingsInterface } from "@langchain/core/embeddings";
import { VectorStore } from "@langchain/core/vectorstores";
import {
Expand Down
Loading
Loading