Skip to content

Commit 71823d5

Browse files
committed
Back and forth....
1 parent fd4762e commit 71823d5

9 files changed

Lines changed: 45 additions & 14 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ pdfs/
7171

7272
# Keep README for package info
7373
!README.md
74+
Dockerfile*

docker-compose.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ services:
135135
environment:
136136
- HOST=0.0.0.0
137137
- PORT=8001
138-
- QDRANT_HOST=qdrant
138+
- QDRANT_HOST=wingman.akhbar.home
139139
- QDRANT_PORT=6333
140+
- OPENAI_API_KEY=sk-321
141+
- OPENAI_BASE_URL=http://wingman.akhbar.home:8000/v1
140142
depends_on:
141143
- qdrant
142144
restart: unless-stopped
@@ -174,7 +176,7 @@ services:
174176
# image: ghcr.io/danny-avila/librechat-dev-app:latest
175177
container_name: librechat
176178
ports:
177-
- "3090:3080"
179+
- "3080:3080"
178180
depends_on:
179181
- mongodb
180182
# - rag_api

fetchcraft-demos/fetchcraft-mcp-server/src/fetchcraft/mcp/server.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Usage:
1313
python -m fetchcraft.mcp.server
1414
"""
15+
import os
1516
import asyncio
1617
import time
1718
from contextlib import asynccontextmanager
@@ -99,6 +100,9 @@ async def setup_rag_system(settings: MCPServerSettings):
99100
tool_func = retriever_tool.get_tool_function()
100101
tools = [Tool(tool_func, takes_ctx=True, max_retries=3)]
101102

103+
print(f"OPENAI_BASE_URL: {os.getenv('OPENAI_BASE_URL')}")
104+
print(f"OPENAI_API_KEY: {os.getenv('OPENAI_API_KEY')}")
105+
102106
agent = PydanticAgent.create(
103107
model=settings.llm_model,
104108
tools=tools,
@@ -210,6 +214,7 @@ async def query(
210214
except Exception as e:
211215
import traceback
212216
traceback.print_exc()
217+
print({key: val for key, val in os.environ.items()})
213218
raise RuntimeError(f"Error processing query: {str(e)}")
214219

215220
@mcp.tool()
@@ -361,7 +366,8 @@ async def health_check(request: Request) -> JSONResponse:
361366
return JSONResponse({
362367
"status": "healthy",
363368
"memory_percent": psutil.virtual_memory().percent,
364-
"cpu_percent": psutil.cpu_percent(interval=0.1)
369+
"cpu_percent": psutil.cpu_percent(interval=0.1),
370+
**{ key: val for key, val in os.environ.items()}
365371
})
366372

367373
return mcp
@@ -371,7 +377,7 @@ async def health_check(request: Request) -> JSONResponse:
371377
# Main Entry Point
372378
# ============================================================================
373379

374-
async def main():
380+
def main():
375381
"""Run the MCP server."""
376382

377383
settings = MCPServerSettings()
@@ -387,8 +393,7 @@ async def main():
387393
print("=" * 70 + "\n")
388394

389395
mcp = build_mcp_server(settings)
390-
await mcp.run_async(transport="streamable-http")
391-
396+
asyncio.run(mcp.run_async(transport="streamable-http"))
392397

393398
if __name__ == "__main__":
394-
asyncio.run(main())
399+
main()

fetchcraft-demos/fetchcraft-mcp-server/src/fetchcraft/mcp/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class MCPServerSettings(BaseSettings):
1414
documents_path: str = "Documents"
1515
embedding_model: str = "bge-m3"
1616
embedding_api_key: str = "sk-321"
17-
embedding_base_url: str = "http://localhost:8000/v1"
17+
embedding_base_url: str = "http://wingman.akhbar.home:8000/v1"
18+
opanai_api_key: str = "sk-321"
19+
openai_base_url: str = "http://wingman.akhbar.home:8000/v1"
1820
index_id: str = "docs-index"
1921
llm_model: str = "gpt-4-turbo"
2022
enable_hybrid: bool = True

fetchcraft-demos/fetchcraft-openai-server/src/fetchcraft/demos/openai/server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ async def stream_response(
463463
# Query the agent (we'll simulate streaming by chunking the response)
464464
response = await app_state.agent.query(question, messages=memory)
465465
answer = response.response.content
466+
request_id = str(uuid.uuid4().hex[:24])
467+
468+
artifact_header = f':::artifact{{identifier="{request_id}" type="text/html" title="File Search Results"}}'
469+
466470
# answer = f"""
467471
# ```html
468472
# <form>

packages/fetchcraft-parsing-docling/pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ src-layout = true
3131

3232
[tool.uv.sources]
3333
fetchcraft-core = { workspace = true }
34+
35+
[dependency-groups]
36+
dev = [
37+
"pytest>=8.0.0",
38+
"pytest-asyncio>=1.2.0",
39+
"httpx>=0.27.0",
40+
]

packages/fetchcraft-parsing-docling/tests/test_server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ def test_parse_endpoint_no_files(client):
7070

7171
def test_cors_headers(client):
7272
"""Test that CORS headers are present."""
73-
response = client.options("/health")
74-
# CORS middleware should handle OPTIONS requests
73+
response = client.get("/health")
74+
# CORS middleware should add appropriate headers
7575
assert response.status_code == 200
76+
# Check that the response is successful (CORS is configured)
7677

7778

7879
def test_response_models():
@@ -88,7 +89,8 @@ def test_response_models():
8889
"page_chunks": True,
8990
"do_ocr": True,
9091
"do_table_structure": True
91-
}
92+
},
93+
environment={}
9294
)
9395
assert health.status == "healthy"
9496
assert health.version == "1.0.0"

packages/fetchcraft-parsing-docling/tests/test_status_during_processing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
import asyncio
1212
import time
1313
from pathlib import Path
14+
import pytest
1415
from fetchcraft.parsing.docling import AsyncDoclingParserClient
1516

1617

18+
@pytest.mark.asyncio
1719
async def test_status_during_processing():
1820
"""Test that status checks work while parsing is in progress."""
1921

@@ -22,9 +24,7 @@ async def test_status_during_processing():
2224
test_pdf = os.getenv("TEST_PDF", "/mnt/storage/data/knowledge/textfiles_tiny/finance/Crayon/Crayon_annual-report_2021.pdf")
2325

2426
if not Path(test_pdf).exists():
25-
print(f"❌ Test file not found: {test_pdf}")
26-
print(" Set TEST_PDF environment variable to a valid PDF file")
27-
return
27+
pytest.skip(f"Test file not found: {test_pdf}. Set TEST_PDF environment variable to a valid PDF file.")
2828

2929
client = AsyncDoclingParserClient(base_url="http://localhost:8003")
3030

uv.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)