eaglelandsonce commited on
Commit
147252c
1 Parent(s): 7200ed6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -2
app.py CHANGED
@@ -1,9 +1,64 @@
1
- from crewai import Agent, Task, Crew, Process
2
- import gradio as gr
3
  import os
 
 
 
4
 
5
  os.environ["OPENAI_API_KEY"] = "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"
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  def run_crew(topic):
8
  # Define your agents
9
  researcher = Agent(
@@ -64,3 +119,5 @@ iface = gr.Interface(
64
  )
65
 
66
  iface.launch()
 
 
 
 
 
1
  import os
2
+ import gradio as gr
3
+
4
+ from crewai import Agent, Task, Crew, Process
5
 
6
  os.environ["OPENAI_API_KEY"] = "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"
7
 
8
+ from crewai import Agent, Task, Crew, Process
9
+
10
+ def run_therapy_session(group_size, topic):
11
+ participant_names = ['Alice', 'Bob', 'Charlie', 'Diana', 'Ethan', 'Fiona', 'George', 'Hannah', 'Ivan']
12
+
13
+ if group_size > len(participant_names) + 1: # +1 for the therapist
14
+ return "Group size exceeds the number of available participant names."
15
+
16
+ # Create the therapist agent
17
+ dr_smith = Agent(role='Therapist', goal='Facilitate a supportive group discussion', llm='mixtral', verbose=True)
18
+
19
+ # Create participant agents
20
+ participants = [Agent(role='Group Therapy Participant', goal='Participate in group therapy', llm='mixtral', verbose=True)
21
+ for _ in range(group_size - 1)]
22
+ participants.append(dr_smith) # Add the therapist
23
+
24
+ # Define tasks for each participant
25
+ tasks = [Task(description=f'{name} discusses the topic: {topic}', agent=participant)
26
+ for name, participant in zip(participant_names, participants)]
27
+
28
+ # Instantiate the crew with a sequential process
29
+ therapy_crew = Crew(
30
+ agents=participants,
31
+ tasks=tasks,
32
+ process=Process.sequential,
33
+ verbose=True
34
+ )
35
+
36
+ # Start the group therapy session
37
+ result = therapy_crew.kickoff()
38
+
39
+ # Simulating a conversation (placeholder, adjust based on CrewAI capabilities)
40
+ conversation = "\n".join([f"{name}: [Participant's thoughts on '{topic}']" for name in participant_names[:group_size-1] + ["Dr. Smith"]])
41
+
42
+ return conversation
43
+
44
+ # Gradio interface
45
+ iface = gr.Interface(
46
+ fn=run_therapy_session,
47
+ inputs=[
48
+ gr.Slider(minimum=2, maximum=10, default=5, label="Group Size"),
49
+ gr.Textbox(lines=2, placeholder="Enter a topic or question for discussion", label="Discussion Topic")
50
+ ],
51
+ outputs="text"
52
+ )
53
+
54
+ # Launch the interface
55
+ iface.launch()
56
+
57
+
58
+
59
+ # Choosing topics
60
+
61
+ '''
62
  def run_crew(topic):
63
  # Define your agents
64
  researcher = Agent(
 
119
  )
120
 
121
  iface.launch()
122
+
123
+ '''