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

DOC: Quickstart does not work #171

Closed
GhostDog98 opened this issue Nov 25, 2024 · 2 comments
Closed

DOC: Quickstart does not work #171

GhostDog98 opened this issue Nov 25, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@GhostDog98
Copy link

Issue with current documentation:

When using the quickstart code for local development:

import { RAGApplicationBuilder } from '@llm-tools/embedjs';
import { OllamaEmbeddings } from '@llm-tools/embedjs-ollama';
import { WebLoader } from '@llm-tools/embedjs-loader-web';
import { HNSWDb } from '@llm-tools/embedjs-hnswlib';

const ragApplication = await new RAGApplicationBuilder()
.setModel(new Ollama({ modelName: "llama3.2", baseUrl: 'http://localhost:11434' }))
.setEmbeddingModel(new OllamaEmbeddings({ model: 'nomic-embed-text', baseUrl: 'http://localhost:11434' }))
.setVectorDatabase(new HNSWDb())
.build();

await ragApplication.addLoader({ urlOrContent: 'https://www.forbes.com/profile/elon-musk' })
await ragApplication.addLoader({ urlOrContent: 'https://en.wikipedia.org/wiki/Elon_Musk' })

await ragApplication.query('What is the net worth of Elon Musk today?')
//Answer: The net worth of Elon Musk today is $258.7 billion.

And a package.json of:

{
  "dependencies": {
    "@llm-tools/embedjs": "^0.1.18",
    "@llm-tools/embedjs-hnswlib": "^0.1.18",
    "@llm-tools/embedjs-loader-web": "^0.1.18",
    "@llm-tools/embedjs-ollama": "^0.1.18"
  },
  "devDependencies": {
    "typescript": "^5.7.2"
  }
}

Running using npx ts-node main.ts returns:

/Users/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
main.ts:7:15 - error TS2304: Cannot find name 'Ollama'.

7 .setModel(new Ollama({ modelName: "llama3.2", baseUrl: 'http://localhost:11434' }))
                ~~~~~~
main.ts:12:34 - error TS2353: Object literal may only specify known properties, and 'urlOrContent' does not exist in type 'BaseLoader<Record<string, string | number | boolean>, Record<string, unknown>>'.

12 await ragApplication.addLoader({ urlOrContent: 'https://www.forbes.com/profile/elon-musk' })
                                    ~~~~~~~~~~~~
main.ts:13:34 - error TS2353: Object literal may only specify known properties, and 'urlOrContent' does not exist in type 'BaseLoader<Record<string, string | number | boolean>, Record<string, unknown>>'.

13 await ragApplication.addLoader({ urlOrContent: 'https://en.wikipedia.org/wiki/Elon_Musk' })
                                    ~~~~~~~~~~~~

    at createTSError (/Users/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1551:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1282:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1098:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14) {
  diagnosticCodes: [ 2304, 2353, 2353 ]
}

Is there something I am missing?

@adhityan
Copy link
Collaborator

I think Ollama was not imported. You need to replace the line -

import { OllamaEmbeddings } from '@llm-tools/embedjs-ollama';

with

import { OllamaEmbeddings, Ollama } from '@llm-tools/embedjs-ollama';

I have updated the documentation.

@adhityan adhityan added the question Further information is requested label Nov 26, 2024
@adhityan
Copy link
Collaborator

adhityan commented Dec 1, 2024

This should work. Closing the issue, please reopen if issue persists.

@adhityan adhityan closed this as completed Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants