capradeepgujaran commited on
Commit
07ae5cf
·
verified ·
1 Parent(s): 33a1aec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -7,6 +7,7 @@ import logging
7
  from llama_index import VectorStoreIndex, Document
8
  from llama_index.embeddings import HuggingFaceEmbedding
9
  from llama_index import ServiceContext
 
10
  from groq import Groq
11
  from dotenv import load_dotenv
12
 
@@ -21,8 +22,11 @@ groq_client = Groq(api_key=os.getenv("GROQ_API_KEY"))
21
  # Initialize the embedding model
22
  embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-MiniLM-L6-v2")
23
 
24
- # Initialize the ServiceContext
25
- service_context = ServiceContext.from_defaults(embed_model=embed_model)
 
 
 
26
 
27
  # Initialize the index
28
  index = None
 
7
  from llama_index import VectorStoreIndex, Document
8
  from llama_index.embeddings import HuggingFaceEmbedding
9
  from llama_index import ServiceContext
10
+ from llama_index.llms import HuggingFaceLLM
11
  from groq import Groq
12
  from dotenv import load_dotenv
13
 
 
22
  # Initialize the embedding model
23
  embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/all-MiniLM-L6-v2")
24
 
25
+ # Initialize a local LLM for indexing purposes
26
+ local_llm = HuggingFaceLLM(model_name="gpt2", tokenizer_name="gpt2")
27
+
28
+ # Initialize the ServiceContext with the local LLM
29
+ service_context = ServiceContext.from_defaults(llm=local_llm, embed_model=embed_model)
30
 
31
  # Initialize the index
32
  index = None