Skip to content

Commit 8defb7c

Browse files
devin-ai-integration[bot]Pratyush Shukla
andcommitted
Apply ruff formatting fixes from pre-commit hooks
Co-Authored-By: Pratyush Shukla <[email protected]>
1 parent bdab090 commit 8defb7c

File tree

1 file changed

+53
-60
lines changed

1 file changed

+53
-60
lines changed

docs/compile_llms_txt.py

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
import os
2-
import glob
32
import re
43
from pathlib import Path
54

65

76
def clean_html_content(text):
87
"""Remove HTML tags and clean content for llms.txt compatibility."""
9-
text = re.sub(r'<[^>]+>', '', text)
10-
11-
lines = text.split('\n')
8+
text = re.sub(r"<[^>]+>", "", text)
9+
10+
lines = text.split("\n")
1211
cleaned_lines = []
1312
in_table = False
14-
13+
1514
for line in lines:
1615
stripped = line.strip()
17-
18-
if '|' in stripped and (stripped.startswith('|') or stripped.count('|') >= 2):
16+
17+
if "|" in stripped and (stripped.startswith("|") or stripped.count("|") >= 2):
1918
in_table = True
2019
continue
21-
elif in_table and (stripped.startswith('-') or not stripped):
20+
elif in_table and (stripped.startswith("-") or not stripped):
2221
continue
2322
else:
2423
in_table = False
25-
26-
cleaned_line = re.sub(r'[^\x00-\x7F]+', '', line)
27-
24+
25+
cleaned_line = re.sub(r"[^\x00-\x7F]+", "", line)
26+
2827
if cleaned_line.strip() or (cleaned_lines and cleaned_lines[-1].strip()):
2928
cleaned_lines.append(cleaned_line)
30-
31-
return '\n'.join(cleaned_lines)
29+
30+
return "\n".join(cleaned_lines)
31+
3232

3333
def compile_llms_txt():
3434
"""Compile a comprehensive llms.txt file with actual repository content."""
35-
35+
3636
content = "# AgentOps\n\n"
37-
37+
3838
content += "> AgentOps is the developer favorite platform for testing, debugging, and deploying AI agents and LLM apps. Monitor, analyze, and optimize your agent workflows with comprehensive observability and analytics.\n\n"
39-
39+
4040
try:
4141
with open("../README.md", "r", encoding="utf-8") as f:
4242
readme_content = f.read()
@@ -45,7 +45,7 @@ def compile_llms_txt():
4545
content += cleaned_readme + "\n\n"
4646
except Exception as e:
4747
print(f"Warning: Could not read README.md: {e}")
48-
48+
4949
try:
5050
with open("../CONTRIBUTING.md", "r", encoding="utf-8") as f:
5151
contributing_content = f.read()
@@ -54,15 +54,11 @@ def compile_llms_txt():
5454
content += cleaned_contributing + "\n\n"
5555
except Exception as e:
5656
print(f"Warning: Could not read CONTRIBUTING.md: {e}")
57-
57+
5858
content += "## Core SDK Implementation\n\n"
59-
60-
sdk_files = [
61-
"../agentops/__init__.py",
62-
"../agentops/client/client.py",
63-
"../agentops/sdk/decorators/__init__.py"
64-
]
65-
59+
60+
sdk_files = ["../agentops/__init__.py", "../agentops/client/client.py", "../agentops/sdk/decorators/__init__.py"]
61+
6662
for file_path in sdk_files:
6763
if os.path.exists(file_path):
6864
try:
@@ -72,16 +68,11 @@ def compile_llms_txt():
7268
content += f"### {relative_path}\n\n```python\n{file_content}\n```\n\n"
7369
except Exception as e:
7470
print(f"Warning: Could not read {file_path}: {e}")
75-
71+
7672
content += "## Documentation\n\n"
77-
78-
doc_files = [
79-
"v2/introduction.mdx",
80-
"v2/quickstart.mdx",
81-
"v2/concepts/core-concepts.mdx",
82-
"v1/quickstart.mdx"
83-
]
84-
73+
74+
doc_files = ["v2/introduction.mdx", "v2/quickstart.mdx", "v2/concepts/core-concepts.mdx", "v1/quickstart.mdx"]
75+
8576
for doc_file in doc_files:
8677
if os.path.exists(doc_file):
8778
try:
@@ -90,15 +81,15 @@ def compile_llms_txt():
9081
content += f"### {doc_file}\n\n{file_content}\n\n"
9182
except Exception as e:
9283
print(f"Warning: Could not read {doc_file}: {e}")
93-
84+
9485
content += "## Instrumentation Architecture\n\n"
95-
86+
9687
instrumentation_files = [
9788
"../agentops/instrumentation/__init__.py",
9889
"../agentops/instrumentation/README.md",
99-
"../agentops/instrumentation/providers/openai/instrumentor.py"
90+
"../agentops/instrumentation/providers/openai/instrumentor.py",
10091
]
101-
92+
10293
for file_path in instrumentation_files:
10394
if os.path.exists(file_path):
10495
try:
@@ -111,16 +102,16 @@ def compile_llms_txt():
111102
content += f"### {relative_path}\n\n{file_content}\n\n"
112103
except Exception as e:
113104
print(f"Warning: Could not read {file_path}: {e}")
114-
105+
115106
content += "## Examples\n\n"
116-
107+
117108
example_files = [
118109
"../examples/openai/openai_example_sync.py",
119110
"../examples/crewai/job_posting.py",
120111
"../examples/langchain/langchain_examples.py",
121-
"../examples/README.md"
112+
"../examples/README.md",
122113
]
123-
114+
124115
for file_path in example_files:
125116
if os.path.exists(file_path):
126117
try:
@@ -138,43 +129,45 @@ def compile_llms_txt():
138129
output_path.write_text(content, encoding="utf-8")
139130
print(f"Successfully compiled comprehensive llms.txt to {output_path.absolute()}")
140131
print(f"Total content length: {len(content)} characters")
141-
132+
142133
try:
143134
import llms_txt
135+
144136
print("✅ llms-txt package available for validation")
145-
137+
146138
try:
147139
parsed_content = llms_txt.parse_llms_file(content)
148140
print("✅ llms.txt content successfully parsed by llms-txt library")
149-
150-
title = getattr(parsed_content, 'title', 'Unknown')
151-
summary = getattr(parsed_content, 'summary', 'No summary')
152-
sections = getattr(parsed_content, 'sections', {})
153-
141+
142+
title = getattr(parsed_content, "title", "Unknown")
143+
summary = getattr(parsed_content, "summary", "No summary")
144+
sections = getattr(parsed_content, "sections", {})
145+
154146
import re
155-
link_pattern = r'\[([^\]]+)\]\(([^)]+)\)'
147+
148+
link_pattern = r"\[([^\]]+)\]\(([^)]+)\)"
156149
links = re.findall(link_pattern, content)
157-
158-
print(f"✅ Validation results:")
150+
151+
print("✅ Validation results:")
159152
print(f" - Title: {title}")
160153
print(f" - Summary: {summary[:100]}{'...' if len(summary) > 100 else ''}")
161154
print(f" - Sections parsed: {len(sections)}")
162155
print(f" - Links found: {len(links)}")
163156
print(f" - Content size: {len(content)} characters")
164-
165-
has_h1 = content.startswith('# ')
166-
has_blockquote = '> ' in content[:500] # Check first 500 chars for summary
167-
h2_count = content.count('\n## ')
168-
169-
print(f"✅ Structure validation:")
157+
158+
has_h1 = content.startswith("# ")
159+
has_blockquote = "> " in content[:500] # Check first 500 chars for summary
160+
h2_count = content.count("\n## ")
161+
162+
print("✅ Structure validation:")
170163
print(f" - H1 header: {'✅' if has_h1 else '❌'}")
171164
print(f" - Blockquote summary: {'✅' if has_blockquote else '❌'}")
172165
print(f" - H2 sections: {h2_count}")
173-
166+
174167
except Exception as parse_error:
175168
print(f"⚠️ llms-txt parsing error: {parse_error}")
176169
print("⚠️ Content may not be fully compliant with llms.txt standard")
177-
170+
178171
except ImportError:
179172
print("⚠️ llms-txt package not available, skipping library validation")
180173
print("💡 Install with: pip install llms-txt")

0 commit comments

Comments
 (0)