Skip to content

Commit fa928d7

Browse files
Update README.md
1 parent 6adb144 commit fa928d7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ If bundler is not being used to manage dependencies, install the gem by executin
3232

3333
1. Generate changes to support vectorsearch in your chosen ActiveRecord model
3434

35-
```
35+
```bash
3636
rails generate langchainrb_rails:pgvector --model=Product --llm=openai
3737
```
3838

3939
This adds required dependencies to your Gemfile, creates the initializer file `config/initializers/langchainrb_rails.rb`, database migrations to support vectorsearch, and adds the necessary code to the ActiveRecord model to enable vectorsearch.
4040

4141
2. Bundle && Migrate
4242

43-
```
44-
bundle && rails db:migrate
43+
```bash
44+
bundle install && rails db:migrate
4545
```
4646

4747
3. Set the env var `OPENAI_API_KEY` to your OpenAI API key.
4848

4949
4. Generate embeddings for your model
5050

51-
```
51+
```ruby
5252
[YOUR MODEL].embed!
5353
```
5454

@@ -58,7 +58,7 @@ This can take a while depending on the number of database records.
5858

5959
### Question and Answering
6060

61-
```
61+
```ruby
6262
Product.ask("list the brands of shoes that are in stock")
6363
```
6464

@@ -71,7 +71,7 @@ Returns a `String` with a natural language answer. The answer is assembled using
7171

7272
### Similarity Search
7373

74-
```
74+
```ruby
7575
Product.similarity_search("t-shirt")
7676
```
7777

@@ -83,13 +83,13 @@ Returns ActiveRecord records that most closely match the `query` using Postgres
8383

8484
By default, embeddings are generated by calling the following within your model:
8585

86-
```
86+
```ruby
8787
to_json(except: :embedding)
8888
```
8989

9090
You can override this by defining an `#as_vector` method in your model:
9191

92-
```
92+
```ruby
9393
def as_vector
9494
res = to_json(except: :embedding, :owner_id, :user_id, :category_id)
9595
res.merge({ "owner" => owner.name, "user" => user.name, "category" => category.name })
@@ -98,20 +98,20 @@ end
9898

9999
Re-generate embeddings after modifying this method:
100100

101-
```
101+
```ruby
102102
[YOUR MODEL].embed!
103103
```
104104

105105
## Rails Generators
106106

107107
### PgVector Generator
108108

109-
```
109+
```bash
110110
rails generate langchainrb_rails:pgvector --model=Product --llm=openai
111111
```
112112

113113
### Pinecone Generator - adds vectorsearch to your ActiveRecord model
114-
```
114+
```bash
115115
rails generate langchainrb_rails:pinecone --model=Product --llm=openai
116116
```
117117

@@ -125,6 +125,6 @@ Pinecone Generator does the following:
125125
3. Adds `pinecone` gem to the Gemfile
126126

127127
### Chroma Generator - adds vectorsearch to your ActiveRecord model
128-
```
128+
```bash
129129
rails generate langchainrb_rails:chroma --model=Product --llm=openai
130130
```

0 commit comments

Comments
 (0)