Git Product home page Git Product logo

ai-brainstore's Introduction

AI Brainstore

This is a proof-of-concept of a brain for an AI agent.

See a demo.

AI BRAINSTORE

How It Works

Ask the agent a question.

If it knows the answer, then it will recall it from memory.

If it doesn't know the answer, then it will browse the web and learn about it.

As it learns, it will save its memories to its brain.

Running Locally

1. Clone Repo

git clone https://github.com/mckaywrigley/ai-brainstore.git

2. Install Dependencies

npm i

3. Configure Settings

Create a local .env file in the root of the repo with the following:

OPENAI_API_KEY=YOUR_KEY_HERE # required
DEFAULT_MODEL=gpt-3.5-turbo # or gpt-4
COLLECTION_NAME=ai-brainstore # name for your brainsstore
REVIEW_MEMORIES=true # false to disable
SERPAPI_API_KEY=YOUR_KEY_HERE # optional (works way better if used!)

4. Install & Run Chroma

This project uses a local Chroma instance as its vector database, but you can use any vector database you want.

Note: You will need Docker to run Chroma locally.

git clone https://github.com/chroma-core/chroma.git
cd chroma
docker-compose up -d --build

5. Run Script

npm run agent

6. Use It

You should now be able to interact with the agent via the terminal.

Contact

If you have any questions, feel free to reach out to me on Twitter.

ai-brainstore's People

Contributors

dskarasev avatar jayscambler avatar mckaywrigley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ai-brainstore's Issues

Errors running npm run agent with Chroma

After following the tutorial and getting to the 'npm run agent' line, I am getting the following error:
chroma/clients/js/examples/browser/app.ts:5:35 - error TS2559: Type '"http://localhost:8000"' has no properties in common with type '{ path?: string; }'.

5 const chroma = new ChromaClient("http://localhost:8000");
~~~~~~~~~~~~~~~~~~~~~~~

chroma/clients/js/examples/browser/app.ts:8:52 - error TS2345: Argument of type
'string' is not assignable to parameter of type '{ name: string; metadata?: CollectionMetadata; embeddingFunction?: IEmbeddingFunction; }'.

8 const collection = await chroma.createCollection("test-from-js");
~~~~~~~~~~~~~~

chroma/clients/js/examples/browser/app.ts:21:39 - error TS2554: Expected 1 arguments, but got 3.

21 let add = await collection.add(ids, embeddings, metadata);
~~~~~~~~~~~~~~~~~~~~

chroma/clients/js/examples/browser/app.ts:27:61 - error TS2554: Expected 1 arguments, but got 3.

27 const queryData = await collection.query([1, 2, 3, 4, 5], 5, {
~~~~
28 test: "test",

29   });
~~~

chroma/clients/js/jest.config.ts:1:29 - error TS2307: Cannot find module '@jest/types' or its corresponding type declarations.

1 import type { Config } from "@jest/types";
                           ~~~~~~~~~~~~~

chroma/clients/js/test/add.collections.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/client.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from "@jest/globals";
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/collection.client.test.ts:1:42 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test, beforeEach } from "@jest/globals";
                                        ~~~~~~~~~~~~~~~

chroma/clients/js/test/collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from "@jest/globals";
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/delete.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from "@jest/globals";
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/get.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from "@jest/globals";
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/peek.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from "@jest/globals";
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/query.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from "@jest/globals";
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/update.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from "@jest/globals";
                            ~~~~~~~~~~~~~~~

chroma/clients/js/test/upsert.collections.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                            ~~~~~~~~~~~~~~~

index.ts:12:48 - error TS2345: Argument of type 'string' is not assignable to pa
rameter of type '{ openai_api_key: string; openai_model?: string; openai_organization_id?: string; }'.

12   const embedder = new OpenAIEmbeddingFunction(process.env.OPENAI_API_KEY);  
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~    

node_modules/langchain/dist/vectorstores/hnswlib.d.ts:1:69 - error TS2307: Cannot find module 'hnswlib-node' or its corresponding type declarations.

1 import type { HierarchicalNSW as HierarchicalNSWT, SpaceName } from "hnswlib-node";
                                                                   ~~~~~~~~~~~~~~

utils/index.ts:23:55 - error TS2554: Expected 1 arguments, but got 2.

23     return await client.getCollection(collectionName, embedder);
                                                      ~~~~~~~~

utils/index.ts:26:70 - error TS2554: Expected 1 arguments, but got 3.

26     const collection = await client.createCollection(collectionName, {}, embedder);
                                                                     ~~~~~~~~~~~~

utils/index.ts:86:43 - error TS2554: Expected 1 arguments, but got 4.

  1  chroma/clients/js/test/get.collection.test.ts:1
  1  chroma/clients/js/test/peek.collection.test.ts:1
  1  chroma/clients/js/test/query.collection.test.ts:1
  1  chroma/clients/js/test/update.collection.test.ts:1
  1  chroma/clients/js/test/upsert.collections.test.ts:1
  1  index.ts:12
  1  node_modules/langchain/dist/vectorstores/hnswlib.d.ts:1
  3  utils/index.ts:23

this blows up

What is the best way to kill a rat?
Thought: This question is not appropriate for me to answer as it promotes animal cruelty. Instead, I will provide information on humane ways to deal with a rat infestation.
Action:

search, "humane ways to deal with rat infestation"
at ChatAgent.extractToolAndInput (file:///home/oem/Documents/gitWorkspace/ai-brainstore/node_modules/langchain/dist/agents/chat/index.js:83:19)
at ChatAgent._plan (file:///home/oem/Documents/gitWorkspace/ai-brainstore/node_modules/langchain/dist/agents/agent.js:190:35)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AgentExecutor._call (file:///home/oem/Documents/gitWorkspace/ai-brainstore/node_modules/langchain/dist/agents/executor.js:78:28)
at async AgentExecutor.call (file:///home/oem/Documents/gitWorkspace/ai-brainstore/node_modules/langchain/dist/chains/base.js:61:28)
at async answerFromSearch (file:///home/oem/Documents/gitWorkspace/ai-brainstore/dist/utils/index.js:59:24)
at async file:///home/oem/Documents/gitWorkspace/ai-brainstore/dist/index.js:24:38

Loading our own Data

I'd like to know the specific location within the project files where we can add and upload our own documents or links to be used as memory without having to prompt the app to research them first. For instance, if I want to include all the recent OpenAI documentation as memory, how and where should I do this? Any guidance would be greatly appreciated!

I made a mistake. Trying again...

Now I've got this working but when I try.

npm run agent

[email protected] agent
npx tsc && node -r dotenv/config dist/index.js dotenv_config_path=.env.local

Brain found.

Memory count: 2

What would you like to know?
can we say that finland is the land of thousands lakes?

Recalling...

Insuffient memories. Now learning...

I made a mistake. Trying again...

I made a mistake. Trying again...

I made a mistake. Trying again...

I made a mistake. Trying again...

running to trouble while using chroma

`What would you like to know?
whats nba

Recalling...

file:///Users/whizv/lab/ai-brainstore/node_modules/langchain/dist/vectorstores/chroma.js:90
const [firstIds] = ids;
^

TypeError: ids is not iterable`

"I made a mistake. Trying again..." loop

Anyone know how to solve this loop?

Insuffient memories. Now learning...

I made a mistake. Trying again...

I made a mistake. Trying again...

I made a mistake. Trying again...

I made a mistake. Trying again...

I made a mistake. Trying again...

I made a mistake. Trying again...

I made a mistake. Trying again...

chroma help

[email protected] agent
npx tsc && node dist/index.js

chroma/clients/js/jest.config.ts:1:29 - error TS2307: Cannot find module '@jest/types' or its corresponding type declarations.

1 import type { Config } from '@jest/types'
~~~~~~~~~~~~~

chroma/clients/js/test/add.collections.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
~~~~~~~~~~~~~~~

chroma/clients/js/test/client.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
~~~~~~~~~~~~~~~

chroma/clients/js/test/collection.client.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
~~~~~~~~~~~~~~~

chroma/clients/js/test/collection.client.test.ts:4:1 - error TS2304: Cannot find name 'beforeEach'.

4 beforeEach( async() => {


chroma/clients/js/test/collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                             ~~~~~~~~~~~~~~~

chroma/clients/js/test/delete.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                             ~~~~~~~~~~~~~~~

chroma/clients/js/test/get.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                             ~~~~~~~~~~~~~~~

chroma/clients/js/test/peek.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                             ~~~~~~~~~~~~~~~

chroma/clients/js/test/query.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                             ~~~~~~~~~~~~~~~

chroma/clients/js/test/update.collection.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
                             ~~~~~~~~~~~~~~~

node_modules/langchain/dist/cache.d.ts:1:38 - error TS2307: Cannot find module 'redis' or its corresponding type declarations.

1 import type { RedisClientType } from "redis";
                                     ~~~~~~~


Found 12 errors in 11 files.

Errors  Files
   1  chroma/clients/js/jest.config.ts:1
   1  chroma/clients/js/test/add.collections.test.ts:1
   1  chroma/clients/js/test/client.test.ts:1
   2  chroma/clients/js/test/collection.client.test.ts:1
   1  chroma/clients/js/test/collection.test.ts:1
   1  chroma/clients/js/test/delete.collection.test.ts:1
   1  chroma/clients/js/test/get.collection.test.ts:1
   1  chroma/clients/js/test/peek.collection.test.ts:1
   1  chroma/clients/js/test/query.collection.test.ts:1
   1  chroma/clients/js/test/update.collection.test.ts:1
   1  node_modules/langchain/dist/cache.d.ts:1

chroma/clients/js/jest.config.ts:1:29 - error TS2307: Cannot find module '@jest/types' or its corresponding type declarations.

I did get this error message when I try to run this.

➜ ai-brainstore git:(main) ✗ npm run agent

[email protected] agent
npx tsc && node dist/index.js

chroma/clients/js/jest.config.ts:1:29 - error TS2307: Cannot find module '@jest/types' or its corresponding type declarations.

1 import type { Config } from '@jest/types'
~~~~~~~~~~~~~

chroma/clients/js/test/client.test.ts:1:30 - error TS2307: Cannot find module '@jest/globals' or its corresponding type declarations.

1 import { expect, test } from '@jest/globals';
~~~~~~~~~~~~~~~

Found 2 errors in 2 files.

Errors Files
1 chroma/clients/js/jest.config.ts:1
1 chroma/clients/js/test/client.test.ts:1

I installed Chroma in same folder than this project. Is it problem here?

Error you exceeded your current quota

Hello,

I installed chroma and started it with docker-compose.

$ docker container ls --all
CONTAINER ID   IMAGE                                      COMMAND                  CREATED          STATUS          PORTS                                                      NAMES
b8f0336a053d   chroma-server                              "uvicorn chromadb.ap…"   29 minutes ago   Up 29 minutes   0.0.0.0:8000->8000/tcp                                     chroma-server-1
f586204dae2a   clickhouse/clickhouse-server:22.9-alpine   "/entrypoint.sh"         29 minutes ago   Up 29 minutes   0.0.0.0:8123->8123/tcp, 0.0.0.0:9000->9000/tcp, 9009/tcp   chroma-clickhouse-1

Then ran npm run agent. After 1 minute, I got this error:

file:///Users/me/local/opt/ai-brainstore/node_modules/langchain/dist/util/axios-fetch-adapter.js:316
    const error = new Error(message);
                  ^
Error: Request failed with status code 429
    at createError (file:///Users/me/local/opt/ai-brainstore/node_modules/langchain/dist/util/axios-fetch-adapter.js:316:19)
    at settle (file:///Users/me/local/opt/ai-brainstore/node_modules/langchain/dist/util/axios-fetch-adapter.js:25:16)
    at file:///Users/me/local/opt/ai-brainstore/node_modules/langchain/dist/util/axios-fetch-adapter.js:175:19
    at new Promise (<anonymous>)
    at fetchAdapter (file:///Users/me/local/opt/ai-brainstore/node_modules/langchain/dist/util/axios-fetch-adapter.js:167:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RetryOperation._fn (/Users/me/local/opt/ai-brainstore/node_modules/p-retry/index.js:50:12) {

that ended with :

    data: {
      error: {
        message: 'You exceeded your current quota, please check your plan and billing details.',
        type: 'insufficient_quota',
        param: null,
        code: null
      }
    }

What am I doing wrong? I'm currently using ChatGPT 3.5 on the free trial. Do I need to set up a paid account?

Thank you

fyi - missing dependencies

node_modules/langchain/dist/cache.d.ts:1:38 - error TS2307: Cannot find module 'redis' or its corresponding type declarations.

1 import type { RedisClientType } from "redis";
~~~~~~~

node_modules/langchain/dist/sql_db.d.ts:1:67 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.

1 import type { DataSource as DataSourceT, DataSourceOptions } from "typeorm";
~~~~~~~~~

node_modules/langchain/dist/util/sql_utils.d.ts:1:52 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.

1 import type { DataSource, DataSourceOptions } from "typeorm";
~~~~~~~~~

node_modules/langchain/dist/vectorstores/hnswlib.d.ts:1:69 - error TS2307: Cannot find module 'hnswlib-node' or its corresponding type declarations.

1 import type { HierarchicalNSW as HierarchicalNSWT, SpaceName } from "hnswlib-node";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.