Wajahat698 commited on
Commit
d98a385
·
verified ·
1 Parent(s): 50e4e16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -441,7 +441,7 @@ def load_main_data_source():
441
  # Use a more robust text splitter
442
  text_splitter = RecursiveCharacterTextSplitter(
443
  chunk_size=2000, # Adjust the chunk size based on your LLM's token limit
444
- chunk_overlap=500, # Add overlap to improve context continuity
445
  )
446
  main_texts = text_splitter.split_text(main_content)
447
 
@@ -1112,20 +1112,19 @@ def rag_response(query):
1112
  # Generate AI response with the retrieved context
1113
  prompt = f"""
1114
  Context:
1115
- {context}
1116
- You are an expert assistant tasked with providing precise and accurate answers based only on the provided context.
1117
 
1118
  1. Use only the provided context to generate your answer.
1119
  2. Match headings and content exactly as they appear in the knowledge base. Do not add, modify, or generalize content.
1120
 
1121
- 3. Maintain clarity, conciseness, and accuracy.
1122
 
1123
  Question:
1124
  {query}
1125
 
1126
  Answer:
1127
  """
1128
- llm = ChatOpenAI(model="gpt-4", temperature=0.2, api_key=openai_api_key)
1129
  response = llm.invoke(prompt)
1130
 
1131
  return response.content.strip()
 
441
  # Use a more robust text splitter
442
  text_splitter = RecursiveCharacterTextSplitter(
443
  chunk_size=2000, # Adjust the chunk size based on your LLM's token limit
444
+ chunk_overlap=750, # Add overlap to improve context continuity
445
  )
446
  main_texts = text_splitter.split_text(main_content)
447
 
 
1112
  # Generate AI response with the retrieved context
1113
  prompt = f"""
1114
  Context:
1115
+ You are an expert tasked with generating accurate and verbatim content directly from the source file. Do not add or interpret content. Match headings and details exactly as they appear.
 
1116
 
1117
  1. Use only the provided context to generate your answer.
1118
  2. Match headings and content exactly as they appear in the knowledge base. Do not add, modify, or generalize content.
1119
 
1120
+ 3. Maintain clarity and accuracy.
1121
 
1122
  Question:
1123
  {query}
1124
 
1125
  Answer:
1126
  """
1127
+ llm = ChatOpenAI(model="gpt-4o", temperature=0.2, api_key=openai_api_key)
1128
  response = llm.invoke(prompt)
1129
 
1130
  return response.content.strip()