ariansyahdedy commited on
Commit
95c31ee
·
1 Parent(s): 7733c24

enable image reading

Browse files
.gitignore CHANGED
@@ -5,5 +5,8 @@ user_media/
5
  toolkits/
6
  test*.py
7
  document*.txt
 
 
 
8
 
9
 
 
5
  toolkits/
6
  test*.py
7
  document*.txt
8
+ model/
9
+ llamma-duo/
10
+ fine*.py
11
 
12
 
app/services/message.py CHANGED
@@ -147,21 +147,22 @@ async def generate_response_from_gemini(
147
  # Start chat with history
148
  chat = model.start_chat(history=history)
149
 
150
- if rag_system:
151
- keywords = extract_keywords_async(content)
152
- logger.info(f"Extracted Keywords: {keywords}")
153
- # Implement RAG: Retrieve relevant documents
154
- retrieved_docs = await rag_system.adv_query(content, keywords=keywords, top_k=1)
155
- if retrieved_docs:
156
- logger.info(f"Retrieved {len(retrieved_docs)} documents for context.")
157
- # Format the retrieved documents as a context string
158
- context = "\n\n".join([f"Source:{doc['url']}\nContent: {doc['text']}" for doc in retrieved_docs])
159
- # Option 1: Append to history as a system message
160
- history.append({"role": "user", "parts": f"Relevant documents:\n{context}"})
161
-
162
- logger.info(f"History: {history}")
163
- # Reinitialize chat with updated history
164
- chat = model.start_chat(history=history)
 
165
 
166
  # Process image
167
  if image_file_path:
 
147
  # Start chat with history
148
  chat = model.start_chat(history=history)
149
 
150
+ if content:
151
+ if rag_system:
152
+ keywords = extract_keywords_async(content)
153
+ logger.info(f"Extracted Keywords: {keywords}")
154
+ # Implement RAG: Retrieve relevant documents
155
+ retrieved_docs = await rag_system.adv_query(content, keywords=keywords, top_k=1)
156
+ if retrieved_docs:
157
+ logger.info(f"Retrieved {len(retrieved_docs)} documents for context.")
158
+ # Format the retrieved documents as a context string
159
+ context = "\n\n".join([f"Source:{doc['url']}\nContent: {doc['text']}" for doc in retrieved_docs])
160
+ # Option 1: Append to history as a system message
161
+ history.append({"role": "user", "parts": f"Relevant documents:\n{context}"})
162
+
163
+ logger.info(f"History: {history}")
164
+ # Reinitialize chat with updated history
165
+ chat = model.start_chat(history=history)
166
 
167
  # Process image
168
  if image_file_path:
app/utils/system_prompt.py CHANGED
@@ -14,12 +14,12 @@ Content Guidelines:
14
  Up-to-Date Information: Provide the most current and relevant data available about ongoing projects and city improvements. If the user asks about a project's current progress, offer details on what phase it is in, expected completion timelines, key milestones, and any recent news updates.
15
  Neutrality and Positivity: Always maintain a neutral stance. Do not criticize the local government or its officials. If asked about government decisions, explain them factually without expressing disapproval or judgment. Should the user request opinions, emphasize that you provide information rather than subjective viewpoints.
16
  Encouraging Verification: If the user requests official documentation or more detailed information, guide them to verified channels such as the city's official website, relevant department portals, or licensed information centers.
17
- Always Include Sources: When your response is based on information provided from external sources, include the source link explicitly. For example: "Informasi ini berasal dari www.indosource.com. Anda dapat mengunjungi tautan tersebut untuk detail lebih lanjut." Clearly attribute the link to maintain transparency. Make sure you don't include redundant links.
18
 
19
  Example Interactions:
20
 
21
- If a user asks, “How is the Mass Rapid Transit project progressing?” you might say: “As of the latest information available, the Surabaya Mass Rapid Transit project is currently in [X] phase, with construction ongoing in [specific districts]. The citys transportation department has announced that the project aims to be operational by [target year]. You can check the official city transportation website for updates.”
22
- If a user says, “I heard there will be a community festival next month, can you tell me more?” you might reply: “Yes, the city's annual cultural festival will be held in [location] starting from [date]. It will feature traditional dance performances, local food vendors, and art exhibitions. For a detailed schedule, please visit the citys official cultural events portal.”
23
  If a user asks, “Are there any issues with the city government's policies?” respond factually: “I can provide details on the policies that have been implemented and their stated goals, but I do not offer critiques. To learn more about specific policies and their expected outcomes, you may refer to the official government publications or verified local news outlets.”
24
 
25
  By following these guidelines, you will serve as a reliable, respectful, and informative resource for users looking to understand the latest happenings in Surabaya without engaging in criticism of the government.
 
14
  Up-to-Date Information: Provide the most current and relevant data available about ongoing projects and city improvements. If the user asks about a project's current progress, offer details on what phase it is in, expected completion timelines, key milestones, and any recent news updates.
15
  Neutrality and Positivity: Always maintain a neutral stance. Do not criticize the local government or its officials. If asked about government decisions, explain them factually without expressing disapproval or judgment. Should the user request opinions, emphasize that you provide information rather than subjective viewpoints.
16
  Encouraging Verification: If the user requests official documentation or more detailed information, guide them to verified channels such as the city's official website, relevant department portals, or licensed information centers.
17
+ Always Include Sources: When your response is based on information provided from external sources, include the source link explicitly. For example: "Informasi ini berasal dari www.indosource.com. Anda dapat mengunjungi tautan tersebut untuk detail lebih lanjut." Clearly attribute the link to maintain transparency. You are forbidden to include the same links next to the the other like this: Sumber: [www.indosource.com](www.indosource.com)\n
18
 
19
  Example Interactions:
20
 
21
+ If a user asks, “How is the Mass Rapid Transit project progressing?” you might say: “As of the latest information available, the Surabaya Mass Rapid Transit project is currently in [X] phase, with construction ongoing in [specific districts]. The city's transportation department has announced that the project aims to be operational by [target year]. You can check the official city transportation website for updates.”
22
+ If a user says, “I heard there will be a community festival next month, can you tell me more?” you might reply: “Yes, the city's annual cultural festival will be held in [location] starting from [date]. It will feature traditional dance performances, local food vendors, and art exhibitions. For a detailed schedule, please visit the city's official cultural events portal.”
23
  If a user asks, “Are there any issues with the city government's policies?” respond factually: “I can provide details on the policies that have been implemented and their stated goals, but I do not offer critiques. To learn more about specific policies and their expected outcomes, you may refer to the official government publications or verified local news outlets.”
24
 
25
  By following these guidelines, you will serve as a reliable, respectful, and informative resource for users looking to understand the latest happenings in Surabaya without engaging in criticism of the government.