Skip to content

Commit b0c8f07

Browse files
author
Thordata
committed
chore: fix lint/format issues to make CI green
1 parent 01e4bc9 commit b0c8f07

File tree

12 files changed

+232
-178
lines changed

12 files changed

+232
-178
lines changed

examples/batch_example.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,51 +30,55 @@ def main():
3030
# Example 1: Batch Scraping
3131
print("📦 Example 1: Batch Scraping")
3232
print("-" * 60)
33-
33+
3434
scrape_tool = ThordataBatchScrapeTool()
35-
35+
3636
urls = [
3737
"https://example.com",
3838
"https://example.org",
3939
"https://example.net",
4040
]
41-
41+
4242
print(f"Scraping {len(urls)} URLs concurrently...")
43-
results = scrape_tool.invoke({
44-
"urls": urls,
45-
"js_render": True,
46-
"concurrency": 3,
47-
})
48-
43+
results = scrape_tool.invoke(
44+
{
45+
"urls": urls,
46+
"js_render": True,
47+
"concurrency": 3,
48+
}
49+
)
50+
4951
print(f"\n✅ Completed {results['total']} requests")
5052
for result in results["results"]:
5153
status = "✓" if result["ok"] else "✗"
5254
print(f" {status} {result['url']}")
5355
if not result["ok"]:
5456
print(f" Error: {result['error']}")
55-
57+
5658
print()
57-
59+
5860
# Example 2: Batch SERP Search
5961
print("🔍 Example 2: Batch SERP Search")
6062
print("-" * 60)
61-
63+
6264
serp_tool = ThordataBatchSerpTool()
63-
65+
6466
queries = [
6567
"Python programming",
6668
"JavaScript frameworks",
6769
"Rust language",
6870
]
69-
71+
7072
print(f"Searching {len(queries)} queries concurrently...")
71-
results = serp_tool.invoke({
72-
"queries": queries,
73-
"engine": "google",
74-
"num": 5,
75-
"concurrency": 3,
76-
})
77-
73+
results = serp_tool.invoke(
74+
{
75+
"queries": queries,
76+
"engine": "google",
77+
"num": 5,
78+
"concurrency": 3,
79+
}
80+
)
81+
7882
print(f"\n✅ Completed {results['total']} searches")
7983
for result in results["results"]:
8084
status = "✓" if result["ok"] else "✗"

examples/openrouter_agent.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
if sys.platform == "win32":
2525
import io
26+
2627
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
2728
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
2829

@@ -50,27 +51,27 @@
5051
def search_and_scrape(query: str):
5152
"""Search and scrape content."""
5253
print(f"🔍 Searching for: '{query}'")
53-
54+
5455
serp = ThordataSerpTool()
5556
results = serp.invoke({"query": query, "num": 1})
56-
57+
5758
if "error" in results or not results.get("organic"):
5859
print(" ❌ Search failed")
5960
return None, None
60-
61+
6162
url = results["organic"][0]["link"]
6263
title = results["organic"][0].get("title", "")
6364
print(f" ✓ Found: {title}")
6465
print(f" 🔗 {url}")
65-
66-
print(f"📝 Converting to Markdown...")
66+
67+
print("📝 Converting to Markdown...")
6768
markdown = ThordataMarkdownTool()
6869
content = markdown.invoke({"url": url, "max_chars": 6000})
69-
70+
7071
if content.startswith("Error"):
7172
print(" ❌ Scrape failed")
7273
return None, None
73-
74+
7475
print(f" ✓ Converted {len(content)} characters")
7576
return content, title
7677

@@ -85,18 +86,18 @@ def summarize_with_openrouter(content: str, topic: str):
8586
"deepseek/deepseek-r1-0528:free",
8687
"z-ai/glm-4.5-air:free",
8788
]
88-
89+
8990
client = OpenAI(
9091
api_key=os.getenv("OPENROUTER_API_KEY"),
9192
base_url="https://openrouter.ai/api/v1",
9293
)
93-
94+
9495
prompt = f"""Summarize the following content about "{topic}" in 3-5 bullet points:
9596
9697
{content[:5000]}
9798
9899
Summary:"""
99-
100+
100101
for model in models:
101102
try:
102103
print(f"🤖 Trying {model}...")
@@ -105,16 +106,16 @@ def summarize_with_openrouter(content: str, topic: str):
105106
messages=[{"role": "user", "content": prompt}],
106107
temperature=0.3,
107108
)
108-
print(f" ✓ Success!")
109+
print(" ✓ Success!")
109110
return response.choices[0].message.content
110111
except Exception as e:
111112
error = str(e)
112113
if "rate-limited" in error or "429" in error:
113-
print(f" ⚠️ Rate-limited, trying next...")
114+
print(" ⚠️ Rate-limited, trying next...")
114115
continue
115116
print(f" ⚠️ Error: {error[:80]}...")
116117
continue
117-
118+
118119
return None
119120

120121

@@ -123,20 +124,20 @@ def main():
123124
print("🚀 Thordata + OpenRouter Agent Demo")
124125
print("=" * 70)
125126
print()
126-
127+
127128
try:
128129
content, title = search_and_scrape("Thordata proxy network features")
129130
if not content:
130131
sys.exit(1)
131-
132+
132133
print()
133134
summary = summarize_with_openrouter(content, title or "Thordata")
134-
135+
135136
if not summary:
136137
print("❌ All models failed. Content preview:")
137138
print(content[:500])
138139
sys.exit(1)
139-
140+
140141
print()
141142
print("=" * 70)
142143
print("📋 Summary:")
@@ -146,10 +147,11 @@ def main():
146147
print("=" * 70)
147148
print("✅ Demo completed!")
148149
print("=" * 70)
149-
150+
150151
except Exception as e:
151152
print(f"\n❌ Error: {e}")
152153
import traceback
154+
153155
traceback.print_exc()
154156
sys.exit(1)
155157

examples/simple_agent_unified.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# With ZhipuAI
88
export ZHIPU_API_KEY=your_key
99
python examples/simple_agent_unified.py zhipu
10-
10+
1111
# With OpenRouter (when available)
1212
export OPENROUTER_API_KEY=your_key
1313
python examples/simple_agent_unified.py openrouter
@@ -18,6 +18,7 @@
1818

1919
if sys.platform == "win32":
2020
import io
21+
2122
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
2223

2324
from dotenv import load_dotenv
@@ -42,6 +43,7 @@
4243
# Summarize
4344
if provider == "zhipu" and os.getenv("ZHIPU_API_KEY"):
4445
from zhipuai import ZhipuAI
46+
4547
client = ZhipuAI(api_key=os.getenv("ZHIPU_API_KEY"))
4648
response = client.chat.completions.create(
4749
model="glm-4-flash",
@@ -50,6 +52,7 @@
5052
print(response.choices[0].message.content)
5153
elif provider == "openrouter" and os.getenv("OPENROUTER_API_KEY"):
5254
from openai import OpenAI
55+
5356
client = OpenAI(
5457
api_key=os.getenv("OPENROUTER_API_KEY"),
5558
base_url="https://openrouter.ai/api/v1",

examples/test_all_features.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
Comprehensive test of all features including new tools.
33
"""
44

5-
import os
65
import sys
76

87
if sys.platform == "win32":
98
import io
9+
1010
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
1111

1212
from dotenv import load_dotenv
@@ -17,8 +17,6 @@
1717
ThordataSerpTool,
1818
ThordataScrapeTool,
1919
ThordataMarkdownTool,
20-
ThordataBatchScrapeTool,
21-
ThordataBatchSerpTool,
2220
ThordataAccountTool,
2321
)
2422

0 commit comments

Comments
 (0)