Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
from crewai import Agent, Task, Crew
|
2 |
import gradio as gr
|
3 |
import asyncio
|
@@ -100,6 +103,8 @@ class ArticleCrew:
|
|
100 |
|
101 |
return [planner_task, writer_task, editor_task]
|
102 |
|
|
|
|
|
103 |
async def process_article(self, topic: str) -> Generator[List[Dict], None, None]:
|
104 |
def add_agent_messages(agent_name: str, tasks: str, emoji: str = "🤖"):
|
105 |
# Add agent header
|
@@ -148,8 +153,8 @@ class ArticleCrew:
|
|
148 |
|
149 |
# Handle the output based on current agent
|
150 |
if self.current_agent == "Editor":
|
151 |
-
#
|
152 |
-
# Instead,
|
153 |
self.message_queue.add_message({
|
154 |
"role": "assistant",
|
155 |
"content": "Final article is ready!",
|
@@ -242,8 +247,9 @@ class ArticleCrew:
|
|
242 |
"metadata": {"title": "❌ Error"}
|
243 |
}]
|
244 |
|
|
|
|
|
245 |
|
246 |
-
# Gradio code
|
247 |
def create_demo():
|
248 |
article_crew = None
|
249 |
|
@@ -263,7 +269,7 @@ def create_demo():
|
|
263 |
type="messages",
|
264 |
show_label=True,
|
265 |
visible=False,
|
266 |
-
|
267 |
render_markdown=True # Enable markdown rendering
|
268 |
)
|
269 |
|
@@ -317,6 +323,7 @@ def create_demo():
|
|
317 |
|
318 |
openai_api_key.submit(show_interface, None, [openai_api_key, chatbot, topic, btn])
|
319 |
btn.click(process_input, [topic, chatbot, openai_api_key], [chatbot])
|
|
|
320 |
|
321 |
return demo
|
322 |
|
|
|
1 |
+
#just formatting things are left now!!
|
2 |
+
# i think we are there now
|
3 |
+
|
4 |
from crewai import Agent, Task, Crew
|
5 |
import gradio as gr
|
6 |
import asyncio
|
|
|
103 |
|
104 |
return [planner_task, writer_task, editor_task]
|
105 |
|
106 |
+
# [Previous code remains the same until the callback functions]
|
107 |
+
|
108 |
async def process_article(self, topic: str) -> Generator[List[Dict], None, None]:
|
109 |
def add_agent_messages(agent_name: str, tasks: str, emoji: str = "🤖"):
|
110 |
# Add agent header
|
|
|
153 |
|
154 |
# Handle the output based on current agent
|
155 |
if self.current_agent == "Editor":
|
156 |
+
# Don't show editor's output with metadata
|
157 |
+
# Instead, show completion message and final article
|
158 |
self.message_queue.add_message({
|
159 |
"role": "assistant",
|
160 |
"content": "Final article is ready!",
|
|
|
247 |
"metadata": {"title": "❌ Error"}
|
248 |
}]
|
249 |
|
250 |
+
# [Rest of the code remains the same]
|
251 |
+
|
252 |
|
|
|
253 |
def create_demo():
|
254 |
article_crew = None
|
255 |
|
|
|
269 |
type="messages",
|
270 |
show_label=True,
|
271 |
visible=False,
|
272 |
+
avatar_images=(None, "https://avatars.githubusercontent.com/u/170677839?v=4"),
|
273 |
render_markdown=True # Enable markdown rendering
|
274 |
)
|
275 |
|
|
|
323 |
|
324 |
openai_api_key.submit(show_interface, None, [openai_api_key, chatbot, topic, btn])
|
325 |
btn.click(process_input, [topic, chatbot, openai_api_key], [chatbot])
|
326 |
+
topic.submit(process_input, [topic, chatbot, openai_api_key], [chatbot])
|
327 |
|
328 |
return demo
|
329 |
|