Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -427,7 +427,11 @@ def load_main_data_source():
|
|
| 427 |
main_content = f.read()
|
| 428 |
|
| 429 |
# Split main content into chunks
|
| 430 |
-
text_splitter =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
main_texts = text_splitter.split_text(main_content)
|
| 432 |
|
| 433 |
# Create Document objects for the main data source
|
|
@@ -1099,7 +1103,30 @@ def rag_response(query):
|
|
| 1099 |
return "No relevant information found in the knowledge base."
|
| 1100 |
|
| 1101 |
# Generate AI response with the retrieved context
|
| 1102 |
-
prompt = f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1103 |
llm = ChatOpenAI(model="gpt-4o", temperature=0.2, api_key=openai_api_key)
|
| 1104 |
response = llm.invoke(prompt)
|
| 1105 |
|
|
@@ -1142,7 +1169,7 @@ prompt_message = f"""
|
|
| 1142 |
** You are a Professional copywriter tasked with creating non-flowery fluid, interconnected marketing content that integrates Trust Builders into various formats for food for the hungry. Your content should be compelling, factual, well-structured, concise, and based on the knowledgebase. Write in an active voice using the first-person perspective ("we"), and avoid the third-person perspective. Creatively interconnect trust-building elements to enhance flow and impact. Avoid using terms like Stability, Development, Competence, Relationship, Benefit, Vision, trust, beacon, beacon of hope, and realm, except where specified.
|
| 1143 |
|
| 1144 |
**IMPORTANT**:
|
| 1145 |
-
- When asked about top trust builders or
|
| 1146 |
- Provide same all statements present in knowledgebase with headings,
|
| 1147 |
*Top Trust Builders for Key Trust Drivers*
|
| 1148 |
[Key Trust Driver name ]
|
|
|
|
| 427 |
main_content = f.read()
|
| 428 |
|
| 429 |
# Split main content into chunks
|
| 430 |
+
text_splitter = RecursiveCharacterTextSplitter(
|
| 431 |
+
chunk_size=2000, # Adjust based on your model's context limit
|
| 432 |
+
chunk_overlap=200, # Ensures continuity between chunks
|
| 433 |
+
separators=["\n\n", "\n", ".", " "]
|
| 434 |
+
)
|
| 435 |
main_texts = text_splitter.split_text(main_content)
|
| 436 |
|
| 437 |
# Create Document objects for the main data source
|
|
|
|
| 1103 |
return "No relevant information found in the knowledge base."
|
| 1104 |
|
| 1105 |
# Generate AI response with the retrieved context
|
| 1106 |
+
prompt = f"""
|
| 1107 |
+
Context:
|
| 1108 |
+
{context}
|
| 1109 |
+
|
| 1110 |
+
You are an expert assistant tasked with generating precise and accurate answers based only on the provided context. Follow these strict rules:
|
| 1111 |
+
1. Use only the provided context to generate your answer.
|
| 1112 |
+
2. Match headings and content exactly as they appear in the knowledge base. Do not add, modify, or generalize content.
|
| 1113 |
+
3. Format responses as follows:
|
| 1114 |
+
```
|
| 1115 |
+
Top Trust Builders for Key Trust Drivers:
|
| 1116 |
+
|
| 1117 |
+
[Key Trust Driver Name]:
|
| 1118 |
+
- [Exact statement from the knowledge base]
|
| 1119 |
+
- [Exact statement from the knowledge base]
|
| 1120 |
+
- [Exact statement from the knowledge base]
|
| 1121 |
+
```
|
| 1122 |
+
|
| 1123 |
+
6. Maintain clarity, conciseness, and accuracy.
|
| 1124 |
+
|
| 1125 |
+
Question:
|
| 1126 |
+
{query}
|
| 1127 |
+
|
| 1128 |
+
Answer:
|
| 1129 |
+
"""
|
| 1130 |
llm = ChatOpenAI(model="gpt-4o", temperature=0.2, api_key=openai_api_key)
|
| 1131 |
response = llm.invoke(prompt)
|
| 1132 |
|
|
|
|
| 1169 |
** You are a Professional copywriter tasked with creating non-flowery fluid, interconnected marketing content that integrates Trust Builders into various formats for food for the hungry. Your content should be compelling, factual, well-structured, concise, and based on the knowledgebase. Write in an active voice using the first-person perspective ("we"), and avoid the third-person perspective. Creatively interconnect trust-building elements to enhance flow and impact. Avoid using terms like Stability, Development, Competence, Relationship, Benefit, Vision, trust, beacon, beacon of hope, and realm, except where specified.
|
| 1170 |
|
| 1171 |
**IMPORTANT**:
|
| 1172 |
+
- When asked about top trust builders or trust builders for key trust drivers find exactly like this use knowledgebase only dont use google. :
|
| 1173 |
- Provide same all statements present in knowledgebase with headings,
|
| 1174 |
*Top Trust Builders for Key Trust Drivers*
|
| 1175 |
[Key Trust Driver name ]
|