-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_simple.py
More file actions
100 lines (77 loc) · 2.84 KB
/
Copy pathexample_simple.py
File metadata and controls
100 lines (77 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
Usage examples - nnprep package
Demonstrates how to use the installed nnprep package for dataset conversion.
"""
# Option 1: use the simple interface (recommended)
from nnprep import convert_dataset
def example_1_simple():
"""Example 1: simplest usage - similar to the original example_1_simple."""
print("\n" + "="*80)
print("Example 1: simplest usage")
print("="*80)
# Option 1a: use the API key from environment variables
result = convert_dataset(
instruction="""
Please convert /Users/gaoyifan/Downloads/m2caiSeg to Dataset702_m2caiSeg.
Note: samples from the train, trainval, and test folders should be merged.
"""
)
print(f"\nFinal result:\n{result}")
def example_2_with_api_key():
"""Example 2: pass the API key explicitly."""
print("\n" + "="*80)
print("Example 2: pass the API key explicitly")
print("="*80)
# Option 1b: pass the API key explicitly
result = convert_dataset(
instruction="""
Please convert /data/my_dataset to Dataset703_MyDataset.
""",
api_key="your-openrouter-api-key" # optional parameter
)
print(f"\nFinal result:\n{result}")
def example_3_with_model():
"""Example 3: specify an LLM model."""
print("\n" + "="*80)
print("Example 3: specify an LLM model")
print("="*80)
result = convert_dataset(
instruction="Please convert /data/test to Dataset704_Test",
model="deepseek/deepseek-v3.2", # specify the model
temperature=0.5 # specify the temperature
)
print(f"\nFinal result:\n{result}")
def example_4_quiet_mode():
"""Example 4: quiet mode (no detailed progress)."""
print("\n" + "="*80)
print("Example 4: quiet mode")
print("="*80)
result = convert_dataset(
instruction="Please convert /data/test to Dataset705_Test",
verbose=False # do not show detailed progress
)
print(f"\nFinal result:\n{result}")
def example_5_advanced():
"""Example 5: advanced usage - use the Agent class directly."""
print("\n" + "="*80)
print("Example 5: advanced usage - use the Agent class directly")
print("="*80)
from nnprep import DataConversionAgent
# Create an Agent instance
agent = DataConversionAgent(
api_key="your-api-key", # optional
verbose=True
)
# The same agent instance can be reused
result1 = agent.run("Please convert /data/dataset1 to Dataset706_Dataset1")
print(f"\nFirst conversion result:\n{result1}")
result2 = agent.run("Please convert /data/dataset2 to Dataset707_Dataset2")
print(f"\nSecond conversion result:\n{result2}")
if __name__ == "__main__":
# Run example
example_1_simple()
# Uncomment to run the other examples
# example_2_with_api_key()
# example_3_with_model()
# example_4_quiet_mode()
# example_5_advanced()