Kryko7 commited on
Commit
8d4348e
1 Parent(s): 85b2df4

updated the app.py

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-311.pyc +0 -0
  2. app.py +7 -2
__pycache__/app.cpython-311.pyc ADDED
Binary file (9.97 kB). View file
 
app.py CHANGED
@@ -3,6 +3,7 @@ import requests
3
  from bs4 import BeautifulSoup
4
  import difflib
5
  from langchain.document_loaders import GutenbergLoader
 
6
 
7
 
8
  import langchain
@@ -117,14 +118,16 @@ def create_book_embeddings(book_content):
117
 
118
 
119
  vectordb = None
 
120
  try:
121
- vectordb = Chroma.load(persist_directory = Configuration.Persist_directory,
122
  collection_name = 'book')
123
  except:
124
  vectordb = Chroma.from_documents(documents = texts,
125
  embedding = instructor_embeddings,
126
- persist_directory = Configuration.Persist_directory,
127
  collection_name = 'book')
 
128
 
129
  vectordb.add_documents(documents=texts, embedding=instructor_embeddings)
130
  vectordb.persist()
@@ -192,6 +195,8 @@ def generate_answer_from_embeddings(query, book_embeddings):
192
 
193
 
194
  app = FastAPI()
 
 
195
  llm = Replicate(
196
  model= "replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf",
197
  input={"temperature": 0.75, "max_length": 500, "top_p": 1},
 
3
  from bs4 import BeautifulSoup
4
  import difflib
5
  from langchain.document_loaders import GutenbergLoader
6
+ import os
7
 
8
 
9
  import langchain
 
118
 
119
 
120
  vectordb = None
121
+ print("Creating book embeddings...")
122
  try:
123
+ vectordb = Chroma.load(persist_directory = '.',
124
  collection_name = 'book')
125
  except:
126
  vectordb = Chroma.from_documents(documents = texts,
127
  embedding = instructor_embeddings,
128
+ persist_directory = '.',
129
  collection_name = 'book')
130
+ print("Book embeddings created.")
131
 
132
  vectordb.add_documents(documents=texts, embedding=instructor_embeddings)
133
  vectordb.persist()
 
195
 
196
 
197
  app = FastAPI()
198
+ REPLICATE_API_TOKEN="r8_KWM7ZPHF27SufFBDWyTQdAHvU07aUHm2aUjQh"
199
+ os.environ["REPLICATE_API_TOKEN"] = REPLICATE_API_TOKEN
200
  llm = Replicate(
201
  model= "replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf",
202
  input={"temperature": 0.75, "max_length": 500, "top_p": 1},