mysketches commited on
Commit
c6582f6
·
1 Parent(s): a7cc3bb
Files changed (6) hide show
  1. .gitignore +2 -0
  2. Dockerfile +18 -0
  3. README.md +42 -6
  4. app.py +78 -0
  5. llms.json +52 -0
  6. requirements.txt +2 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .env
2
+ __pycache__/
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3
2
+
3
+ ADD requirements.txt requirements.txt
4
+
5
+ RUN apt-get update && apt-get install -y \
6
+ net-tools \
7
+ iputils-ping \
8
+ curl \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ RUN pip install -r requirements.txt
12
+ RUN mkdir /home/project
13
+
14
+ EXPOSE 7860
15
+
16
+ WORKDIR /home/project
17
+
18
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -1,14 +1,50 @@
1
  ---
2
  title: Llmstxt
3
- emoji: 🌍
4
- colorFrom: indigo
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 5.33.0
8
  app_file: app.py
9
- pinned: false
10
  license: apache-2.0
11
- short_description: Access documentation in your IDE with LLMs.txt
 
 
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Llmstxt
3
+ emoji: 💻
4
+ colorFrom: purple
5
+ colorTo: pink
6
  sdk: gradio
7
  sdk_version: 5.33.0
8
  app_file: app.py
9
+ pinned: true
10
  license: apache-2.0
11
+ short_description: Access documentation in your IDE with llms.txt
12
+ tags:
13
+ - mcp-server-track
14
  ---
15
 
16
+ # Documentation Registry Gradio App
17
+
18
+ This Gradio application provides a simple interface to browse and retrieve documentation entries from a registry defined in a local JSON file (`llms.json`). The app offers two main features:
19
+
20
+ - **Load Registry:**
21
+ View the entire contents of the documentation registry in a formatted JSON view. This helps users see all available documentation entries, including their IDs, descriptions, and URLs.
22
+
23
+ - **Search Documentation by ID:**
24
+ Enter a specific registry ID to fetch and display the corresponding documentation content. The app retrieves the documentation from the URL associated with the provided ID.
25
+
26
+ ## Features
27
+
28
+ - User-friendly web interface built with Gradio.
29
+ - Registry entries are loaded from a local `llms.json` file.
30
+ - Documentation content is fetched live from the URLs specified in the registry.
31
+ - Error handling for missing files, invalid JSON, and network issues.
32
+ - Custom styling for search results.
33
+
34
+ ## How to Use
35
+
36
+ After the MCP server is loaded inside of your IDE, just ask it for some documentation, using prompts like this one:
37
+
38
+ ```text
39
+ I need documentation about Langgraph. In particular, I need to understand how to use cron jobs with the LangGraph Platform
40
+ ```
41
+
42
+ ## Running the App
43
+
44
+ To launch the app, run:
45
+
46
+ ```bash
47
+ python app.py
48
+ ```
49
+
50
+ The app will be available on port `7860`.
app.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import json
4
+
5
+ def load_registry():
6
+ """
7
+ This function (load_registry) should always be called first, before using the load_doc function. It will load the registry file and return the content of the registry. Based on that, you will then be able to pick and chose the documentation you want to load.
8
+ Returns:
9
+ str: The content of the registry, that contains the ID, a description and the URL location for each item of the registry, in JSON format
10
+ """
11
+ try:
12
+ with open('llms.json', 'r') as file:
13
+ content = json.load(file)
14
+ return "```json\n" + json.dumps(content, indent=2) + "\n```"
15
+ except Exception as error:
16
+ print(f"Error reading llms.json: {error}")
17
+ return f"Error reading file: {str(error)}"
18
+
19
+ def load_doc(query):
20
+ """
21
+ After getting the registry with the load_registry function, you can use this function to load the documentation you want to use.
22
+
23
+ Args:
24
+ query (str): The documentation ID you want to load
25
+
26
+ Returns:
27
+ str: The documentation content
28
+ """
29
+ try:
30
+ # Read the llms.json file
31
+ with open('llms.json', 'r') as file:
32
+ content = json.load(file)
33
+
34
+ matching_entry = next((item for item in content if item['id'] == query), None)
35
+
36
+ if matching_entry is None:
37
+ return f"No documentation found for query: {query}"
38
+
39
+ url = matching_entry['url']
40
+
41
+ response = requests.get(url)
42
+ response.raise_for_status() # Raise an exception for bad status codes
43
+
44
+ return response.text
45
+
46
+ except FileNotFoundError:
47
+ return "Error: registry file not found"
48
+ except json.JSONDecodeError:
49
+ return "Error: Invalid JSON format in registry"
50
+ except requests.RequestException as e:
51
+ return f"Error fetching content from URL: {str(e)}"
52
+ except Exception as e:
53
+ return f"An unexpected error occurred: {str(e)}"
54
+
55
+ css = """
56
+ #search_results {
57
+ background-color: #ffebc3;
58
+ padding: 10px;
59
+ border-radius: 5px;
60
+ }
61
+ """
62
+ with gr.Blocks(css=css) as demo:
63
+ gr.HTML("<center><h1>Documentation registry</h1></center>")
64
+ with gr.Row():
65
+ with gr.Column():
66
+ load_button = gr.Button("Load registry")
67
+ gr.HTML("<center><h2>OR</h2></center>")
68
+ query = gr.Textbox(label="Enter your registry ID")
69
+ search_button = gr.Button("Search documentation by ID")
70
+
71
+ with gr.Column():
72
+ output = gr.Markdown(elem_id="search_results")
73
+
74
+ load_button.click(load_registry, outputs=output)
75
+ search_button.click(load_doc, inputs=query, outputs=output)
76
+
77
+ if __name__ == "__main__":
78
+ demo.launch(mcp_server=True, strict_cors=False)
llms.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "id": "langchain",
4
+ "description": "Open-source framework for developing applications using large language models with simplified tools and APIs.",
5
+ "url": "https://python.langchain.com/llms.txt"
6
+ },
7
+ {
8
+ "id": "langgraph",
9
+ "description": "Open-source framework from LangChain team for building complex stateful multi-agent applications using large language models.",
10
+ "url": "https://langchain-ai.github.io/langgraph/llms.txt"
11
+ },
12
+ {
13
+ "id": "anthropic",
14
+ "description": "API and services for Claude, an advanced AI assistant developed by Anthropic for various natural language processing tasks.",
15
+ "url": "https://docs.anthropic.com/llms.txt"
16
+ },
17
+ {
18
+ "id": "supabase",
19
+ "description": "Open-source Firebase alternative providing a complete backend service suite built on PostgreSQL with authentication, real-time APIs, and storage.",
20
+ "url": "https://supabase.com/llms.txt"
21
+ },
22
+ {
23
+ "id": "mcp",
24
+ "description": "Model Context Protocol for exposing llms.txt files as tools directly to IDEs and LLM agents.",
25
+ "url": "https://modelcontextprotocol.io/llms.txt"
26
+ },
27
+ {
28
+ "id": "langfuse",
29
+ "description": "Observability platform for debugging, analyzing, and iterating on LangGraph and LangChain applications with automatic tracing.",
30
+ "url": "https://langfuse.com/llms.txt"
31
+ },
32
+ {
33
+ "id": "pydantic",
34
+ "description": "Python data validation library using Python type annotations to ensure data integrity.",
35
+ "url": "https://docs.pydantic.dev/latest/llms.txt"
36
+ },
37
+ {
38
+ "id": "crewai",
39
+ "description": "Framework for building multi-agent applications using large language models with multi-LLM provider integration through LiteLLM.",
40
+ "url": "https://docs.crewai.com/llms.txt"
41
+ },
42
+ {
43
+ "id": "docker",
44
+ "description": "Containerization platform using OS-level virtualization to automate application deployment in isolated environments.",
45
+ "url": "https://docs.docker.com/llms.txt"
46
+ },
47
+ {
48
+ "id": "huggingface",
49
+ "description": "State-of-the-art natural language processing library providing pre-trained machine learning models for various NLP tasks.",
50
+ "url": "https://huggingface-projects-docs-llms-txt.hf.space/transformers/llms.txt"
51
+ }
52
+ ]
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ gradio[mcp]