-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic_usage.py
More file actions
53 lines (42 loc) · 1.41 KB
/
basic_usage.py
File metadata and controls
53 lines (42 loc) · 1.41 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
"""Example usage of the prompt generator."""
import os
import sys
# Add the parent directory to sys.path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from services.prompt_service import PromptService
def run_examples():
"""Run example prompt generations."""
# Initialize service
service = PromptService()
# Example prompts
examples = [
{
"prompt": "python code assisant ",
"length": "detailed",
"language": "en",
"description": "Detailed English prompt"
},
{
"prompt": "دستیار ترجمه از انگلیسی به فارسی",
"length": "concise",
"language": "fa",
"description": "Concise Persian prompt"
},
]
# Generate and display results
for example in examples:
print(f"\n{'='*50}")
print(f"Example: {example['description']}")
print(f"{'='*50}")
try:
result = service.generate(
prompt=example["prompt"],
prompt_length=example["length"],
output_language=example["language"]
)
print(service.format_output(result))
except Exception as e:
print(f"Error: {str(e)}")
print(f"{'='*50}\n")
if __name__ == "__main__":
run_examples()