Logeswaransr commited on
Commit
7f5b663
·
verified ·
1 Parent(s): e894d29

Update initialize.py

Browse files
Files changed (1) hide show
  1. initialize.py +6 -9
initialize.py CHANGED
@@ -1,4 +1,4 @@
1
- from haystack import Document
2
  from haystack.document_stores.in_memory import InMemoryDocumentStore
3
  from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
4
  from haystack.components.builders import PromptBuilder
@@ -16,7 +16,7 @@ def init_doc_store(path, files):
16
  document_store.write_documents(docs)
17
  return document_store
18
 
19
- def define_components(document_store):
20
  retriever = InMemoryBM25Retriever(document_store, top_k=3)
21
 
22
  template = """
@@ -32,13 +32,10 @@ def define_components(document_store):
32
  """
33
  prompt_builder = PromptBuilder(template=template)
34
 
35
- generator = HuggingFaceLocalGenerator(model="gpt2",
36
- task="text-generation",
37
- # device='cuda',
38
- generation_kwargs={
39
- "max_new_tokens": 100,
40
- "temperature": 0.9,
41
- })
42
  generator.warm_up()
43
  return retreiver, prompt_builder, generator
44
 
 
1
+ from haystack import Document, Secret
2
  from haystack.document_stores.in_memory import InMemoryDocumentStore
3
  from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
4
  from haystack.components.builders import PromptBuilder
 
16
  document_store.write_documents(docs)
17
  return document_store
18
 
19
+ def define_components(document_store, api_key):
20
  retriever = InMemoryBM25Retriever(document_store, top_k=3)
21
 
22
  template = """
 
32
  """
33
  prompt_builder = PromptBuilder(template=template)
34
 
35
+ generator = HuggingFaceTGIGenerator(
36
+ model="mistralai/Mistral-7B-v0.1",
37
+ token=Secret.from_token(api_key)
38
+ )
 
 
 
39
  generator.warm_up()
40
  return retreiver, prompt_builder, generator
41