cryogenic22 commited on
Commit
e791505
·
verified ·
1 Parent(s): 519a913

Update multi_agent_book_workflow.py

Browse files
Files changed (1) hide show
  1. multi_agent_book_workflow.py +47 -6
multi_agent_book_workflow.py CHANGED
@@ -84,21 +84,22 @@ class BookWritingOrchestrator:
84
  raise
85
 
86
  def _setup_ai_models(self):
87
- """
88
- Configure AI models with robust error handling
89
- """
90
  try:
91
  # LLM Configurations
92
  self.openai_llm = ChatOpenAI(
93
- model="gpt-4-turbo",
94
  temperature=0.7,
95
  api_key=self.openai_api_key
96
  )
97
 
 
98
  self.anthropic_llm = ChatAnthropic(
99
- model='claude-3-opus-20240229',
100
  temperature=0.7,
101
- api_key=self.anthropic_api_key
102
  )
103
 
104
  # Global memory for cross-chapter context
@@ -110,6 +111,46 @@ class BookWritingOrchestrator:
110
  st.error(f"AI model setup failed: {e}")
111
  raise
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  def setup_agents(self):
114
  """
115
  Create specialized agents for book writing workflow
 
84
  raise
85
 
86
  def _setup_ai_models(self):
87
+ """
88
+ Configure AI models with robust error handling
89
+ """
90
  try:
91
  # LLM Configurations
92
  self.openai_llm = ChatOpenAI(
93
+ model="gpt-4-turbo-preview", # Updated model name
94
  temperature=0.7,
95
  api_key=self.openai_api_key
96
  )
97
 
98
+ # Updated Anthropic model configuration
99
  self.anthropic_llm = ChatAnthropic(
100
+ model_name="claude-3-sonnet-20240229", # Updated model name
101
  temperature=0.7,
102
+ anthropic_api_key=self.anthropic_api_key
103
  )
104
 
105
  # Global memory for cross-chapter context
 
111
  st.error(f"AI model setup failed: {e}")
112
  raise
113
 
114
+ def _fallback_book_concept(self, initial_prompt: str) -> Dict[str, Any]:
115
+ """
116
+ Provide a fallback response when book concept generation fails
117
+
118
+ Args:
119
+ initial_prompt (str): Original user prompt
120
+
121
+ Returns:
122
+ Dict: Basic book concept structure
123
+ """
124
+ return {
125
+ "title": "Untitled Project",
126
+ "genre": "General Fiction",
127
+ "target_audience": "General Adult",
128
+ "core_premise": initial_prompt,
129
+ "chapter_outline": ["Chapter 1: Introduction"],
130
+ "narrative_approach": "Standard Third-Person Narrative",
131
+ "status": "fallback_generated"
132
+ }
133
+
134
+ def _fallback_chapter_content(self, book_concept: Dict[str, Any], chapter_number: int) -> str:
135
+ """
136
+ Provide fallback chapter content when generation fails
137
+
138
+ Args:
139
+ book_concept (Dict): Book concept data
140
+ chapter_number (int): Chapter number
141
+
142
+ Returns:
143
+ str: Basic chapter content
144
+ """
145
+ return f"""
146
+ Chapter {chapter_number}
147
+
148
+ [Placeholder content for {book_concept.get('title', 'Untitled')}]
149
+
150
+ This is auto-generated fallback content due to an error in chapter generation.
151
+ Please try regenerating this chapter or contact support if the issue persists.
152
+ """
153
+
154
  def setup_agents(self):
155
  """
156
  Create specialized agents for book writing workflow