Skip to content

Commit

Permalink
update promptHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
ValMobYKang committed Nov 14, 2023
1 parent 6623404 commit 21aea31
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@
from llama_index.embeddings import HuggingFaceEmbedding
from llama_index.node_parser import SimpleNodeParser
from llama_index.text_splitter import TokenTextSplitter

from llama_index.indices.prompt_helper import PromptHelper
# from llama_hub.confluence.base import ConfluenceReader
from utils import ConfluenceReader

os.environ["OPENAI_API_KEY"] = "YOUR_OPENAI_API_KEY"
os.environ["OPENAI_API_BASE"] = "http://localhost:8000/v1"

llm = OpenAI(temperature=0.1, max_tokens=2048)
embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-base-en-v1.5")
LLM = OpenAI(temperature=0.1, max_tokens=2048)
EMBEDDING = HuggingFaceEmbedding(model_name="BAAI/bge-base-en-v1.5")


def init_index():
if os.path.exists("store"):
index = load_index_from_storage(
storage_context=StorageContext.from_defaults(persist_dir="store"),
service_context=ServiceContext.from_defaults(
llm=llm, embed_model=embed_model
llm=LLM,
embed_model=EMBEDDING,
prompt_helper=PromptHelper(chunk_size_limit=2000)
),
)
else:
Expand All @@ -40,7 +42,7 @@ def init_index():
max_num_results=10,
),
service_context=ServiceContext.from_defaults(
llm=llm,
llm=LLM,
node_parser=SimpleNodeParser.from_defaults(
text_splitter=TokenTextSplitter(
separator=" ",
Expand All @@ -49,7 +51,7 @@ def init_index():
backup_separators=["\n"],
)
),
embed_model=embed_model,
embed_model=EMBEDDING,
),
show_progress=True,
)
Expand Down

0 comments on commit 21aea31

Please sign in to comment.