Rifqi Hafizuddin commited on
Commit
9c090a0
·
2 Parent(s): bbc8c5864cd843

Merge branch 'main' of https://huggingface.co/spaces/DataEyond/Agentic-Service-Data-Eyond into dev_new

Browse files
.vscode/launch.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "DataEyond: FastAPI (debug)",
9
+ "type": "debugpy",
10
+ "request": "launch",
11
+ "module": "uvicorn",
12
+ "args": [
13
+ "main:app",
14
+ "--host", "0.0.0.0",
15
+ "--port", "7860",
16
+ "--reload"
17
+ ],
18
+ "jinja": true,
19
+ "justMyCode": true,
20
+ "envFile": "${workspaceFolder}/.env",
21
+ "console": "integratedTerminal",
22
+ "cwd": "${workspaceFolder}"
23
+ }
24
+ ]
25
+ }
README.md CHANGED
@@ -11,6 +11,8 @@ short_description: AI Agent core service
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
 
13
 
 
 
14
  How to run:
15
  `uv run --no-sync uvicorn main:app --host 0.0.0.0 --port 7860`
16
 
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
 
13
 
14
+ # Agentic Service Data Eyond
15
+
16
  How to run:
17
  `uv run --no-sync uvicorn main:app --host 0.0.0.0 --port 7860`
18
 
src/api/v1/chat.py CHANGED
@@ -61,15 +61,30 @@ def _extract_sources(results: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
61
  seen = set()
62
  sources = []
63
  for result in results:
64
- meta = result["metadata"]
65
- key = (meta.get("document_id"), meta.get("page_label"))
66
- if key not in seen:
67
- seen.add(key)
68
- sources.append({
69
- "document_id": meta.get("document_id"),
70
- "filename": meta.get("filename", "Unknown"),
71
- "page_label": meta.get("page_label"),
72
- })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  return sources
74
 
75
 
 
61
  seen = set()
62
  sources = []
63
  for result in results:
64
+ if "document_id" in result["metadata"]["data"]:
65
+ meta = result["metadata"]
66
+ key = (meta.get("document_id"), meta.get("page_label"))
67
+ if key not in seen:
68
+ seen.add(key)
69
+ sources.append({
70
+ "document_id": meta.get("data", {}).get("document_id"),
71
+ "filename": meta.get("data", {}).get("filename", "Unknown"),
72
+ "page_label": meta.get("data", {}).get("page_label", "Unknown"),
73
+ })
74
+ else:
75
+ meta = result["metadata"]
76
+ key = (meta.get("table_name"), meta.get("column_name"))
77
+ if key not in seen:
78
+ seen.add(key)
79
+ table_name = meta.get("data", {}).get("table_name")
80
+ user_id = meta.get("user_id")
81
+ sources.append({
82
+ "document_id": f"{user_id}_{table_name}",
83
+ "filename": meta.get("data", {}).get("table_name", "Unknown"),
84
+ "page_label": meta.get("data", {}).get("column_name", "Unknown"),
85
+ })
86
+
87
+ logger.debug(f"Extracted sources: {sources}")
88
  return sources
89
 
90
 
src/config/agents/system_prompt.md CHANGED
@@ -3,8 +3,7 @@ You are a helpful AI assistant with access to user's uploaded documents. Your ro
3
  1. Answer questions based on provided document context
4
  2. If no relevant information is found in documents, acknowledge this honestly
5
  3. Be concise and direct in your responses
6
- 4. Cite source documents when providing information
7
- 5. If user's question is unclear, ask for clarification
8
 
9
  When document context is provided:
10
  - Use information from documents to answer accurately
 
3
  1. Answer questions based on provided document context
4
  2. If no relevant information is found in documents, acknowledge this honestly
5
  3. Be concise and direct in your responses
6
+ 4. If user's question is unclear, ask for clarification
 
7
 
8
  When document context is provided:
9
  - Use information from documents to answer accurately