-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagents.py
83 lines (64 loc) · 2.91 KB
/
agents.py
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
import logging
from api_handlers import call_gpt4, call_claude, delay_between_calls
class IndustryStrategist:
@classmethod
def generate_outline(cls, document_info, max_tokens):
prompt = f"""As an Industry Strategist with 30 years of experience, create a detailed outline for the following document:
Title: {document_info['title']}
Description: {document_info['description']}
Please provide the outline in markdown format, using '##' to denote main sections and '###' for subsections."""
try:
outline = call_gpt4(prompt, max_tokens)
delay_between_calls()
return outline
except Exception as e:
logging.error(f"Error generating outline: {e}")
raise
class ExpertAuthor:
@classmethod
def generate_content(cls, section, config, max_tokens):
prompt = f"""As an expert author with the following profile: {config['author']['profile']},
write initial content for the following section of a document:
Section: {section}
Document Title: {config['document']['title']}
Document Description: {config['document']['description']}
Please write in a {config['output']['tone']} tone and format the output as a {config['output']['format']}."""
try:
content = call_gpt4(prompt, max_tokens)
delay_between_calls()
return content
except Exception as e:
logging.error(f"Error generating content for section '{section}': {e}")
raise
class CriticalReviewer:
@classmethod
def review_content(cls, content, section, config, max_tokens):
prompt = f"""As a thorough and helpful critic, review the following content for the section "{section}" of the document titled "{config['document']['title']}".
Provide detailed feedback to enhance and improve the content, focusing on extending it with a critical eye and ensuring quality and thoroughness.
Content to review:
{content}
Please provide your feedback and suggestions for improvement."""
try:
feedback = call_gpt4(prompt, max_tokens)
delay_between_calls()
return feedback
except Exception as e:
logging.error(f"Error reviewing content for section '{section}': {e}")
raise
class FinalEditor:
@classmethod
def enhance_content(cls, content, feedback, config, max_tokens):
prompt = f"""As a final editor, please enhance the following content based on the provided feedback:
Initial Content:
{content}
Feedback:
{feedback}
Please maintain a {config['output']['tone']} tone and ensure the output remains in {config['output']['format']} format.
Provide a comprehensive, enhanced version of the content."""
try:
enhanced_content = call_claude(prompt, max_tokens)
delay_between_calls()
return enhanced_content
except Exception as e:
logging.error(f"Error enhancing content: {e}")
raise