MCPcopy Create free account
hub / github.com/Lap-Platform/LAP / LAPDocLoader

Class LAPDocLoader

sdks/python/lap/middleware.py:22–65  ·  view source on GitHub ↗

LangChain-compatible document loader for LAP files.

Source from the content-addressed store, hash-verified

20
21
22class LAPDocLoader(BaseLoader):
23 """LangChain-compatible document loader for LAP files."""
24
25 def __init__(self, path: str, lean: bool = True):
26 self.path = path
27 self.lean = lean
28 self._client = LAPClient()
29
30 def load(self):
31 """Load LAP file as LangChain Document objects."""
32 doc = self._client.load(self.path)
33 documents = []
34
35 # One document per endpoint
36 for ep in doc.endpoints:
37 content = f"{ep.method} {ep.path}"
38 if ep.summary:
39 content += f"\n{ep.summary}"
40 if ep.required_params:
41 params = ", ".join(f"{p.name}: {p.type}" for p in ep.required_params)
42 content += f"\nRequired: {params}"
43 if ep.optional_params:
44 params = ", ".join(f"{p.name}: {p.type}" for p in ep.optional_params)
45 content += f"\nOptional: {params}"
46
47 documents.append(Document(
48 page_content=content,
49 metadata={
50 "source": self.path,
51 "api": doc.api_name,
52 "method": ep.method,
53 "path": ep.path,
54 },
55 ))
56
57 return documents
58
59 def load_full(self):
60 """Load as a single document with full context."""
61 doc = self._client.load(self.path)
62 return [Document(
63 page_content=doc.to_context(lean=self.lean),
64 metadata={"source": self.path, "api": doc.api_name},
65 )]

Callers 3

test_load_documentsMethod · 0.90
test_load_fullMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_load_documentsMethod · 0.72
test_load_fullMethod · 0.72