-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOFMentor-Agency-Setup.py
More file actions
237 lines (192 loc) · 9.63 KB
/
OFMentor-Agency-Setup.py
File metadata and controls
237 lines (192 loc) · 9.63 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
"""
OFMentor Agency Setup
This file demonstrates how to configure and initialize the OFMentor system
using the agency-swarm framework. It defines the agent roles, tools, and
communication patterns necessary to implement the system as described in the PRD.
"""
from agency_swarm import Agent, Agency, set_openai_key
from agency_swarm.tools import BaseTool
from pydantic import Field
import os
# Set your OpenAI API key
# set_openai_key(os.environ.get("OPENAI_API_KEY"))
# Uncomment the line above and set your API key in environment variables
# Or directly set it here (not recommended for production)
# set_openai_key("your-api-key-here")
# Define custom tools for OFMentor system
class YouTubeSearchTool(BaseTool):
"""
Tool for searching YouTube videos related to OnlyFans management.
Finds relevant videos based on keywords and returns basic video information.
"""
keywords: str = Field(..., description="Keywords to search for videos")
max_results: int = Field(10, description="Maximum number of results to return")
def run(self):
# Actual implementation would use YouTube API
# This is a placeholder for demonstration purposes
print(f"Searching YouTube for '{self.keywords}', max results: {self.max_results}")
return f"Found {self.max_results} videos about {self.keywords}"
class TranscriptExtractionTool(BaseTool):
"""
Tool for extracting transcripts from YouTube videos.
Takes a video ID and returns the processed transcript text.
"""
video_id: str = Field(..., description="YouTube video ID to extract transcript from")
def run(self):
# Actual implementation would use YouTube Transcript API
# This is a placeholder for demonstration purposes
print(f"Extracting transcript for video ID: {self.video_id}")
return f"Extracted transcript for video {self.video_id}"
class VectorDBQueryTool(BaseTool):
"""
Tool for querying the vector database to retrieve relevant information.
Takes a query and returns the most relevant chunks from the knowledge base.
"""
query: str = Field(..., description="Query to search for in the knowledge base")
top_k: int = Field(5, description="Number of results to return")
def run(self):
# Actual implementation would query vector database
# This is a placeholder for demonstration purposes
print(f"Searching knowledge base for: '{self.query}', top_k: {self.top_k}")
return f"Retrieved {self.top_k} relevant chunks for query: {self.query}"
class ResponseGenerationTool(BaseTool):
"""
Tool for generating responses based on retrieved context.
Takes user query and retrieved context, returns a formatted response.
"""
query: str = Field(..., description="User's original query")
context: str = Field(..., description="Retrieved context from knowledge base")
def run(self):
# Actual implementation would use LLM to generate response
# This is a placeholder for demonstration purposes
print(f"Generating response for query: '{self.query}' with context")
return f"Generated response for: {self.query} using provided context"
class ChatbotInterfaceTool(BaseTool):
"""
Tool for managing the chatbot interface.
Handles formatting and displaying responses to users.
"""
message: str = Field(..., description="Message to display to user")
format_type: str = Field("standard", description="Format type (standard, detailed, markdown)")
def run(self):
# Actual implementation would format and display the message
# This is a placeholder for demonstration purposes
print(f"Displaying message in {self.format_type} format")
return f"Displayed message: {self.message} in {self.format_type} format"
# Define the agent roles
# These would typically have more detailed instructions in .md files
ceo_agent = Agent(
name="CEO",
description="Central coordinator for the OFMentor system. Manages user interactions and delegates tasks to specialized agents.",
instructions="""
You are the CEO of the OFMentor agency, responsible for:
1. Understanding user queries about OnlyFans management
2. Delegating tasks to appropriate specialist agents
3. Synthesizing information from different agents
4. Ensuring high-quality, coherent responses
5. Managing the overall conversation flow
Always maintain a helpful, informative tone focused on OnlyFans management best practices.
""",
tools=[ChatbotInterfaceTool]
)
knowledge_engineer = Agent(
name="KnowledgeEngineer",
description="Responsible for knowledge acquisition, organization, and maintenance from YouTube content.",
instructions="""
You are the Knowledge Engineer for OFMentor, responsible for:
1. Finding relevant YouTube videos about OnlyFans management
2. Extracting and processing transcripts
3. Organizing knowledge into the vector database
4. Ensuring knowledge freshness and quality
5. Identifying and filling knowledge gaps
Focus on maintaining a high-quality, up-to-date knowledge base of OnlyFans management strategies.
""",
tools=[YouTubeSearchTool, TranscriptExtractionTool]
)
rag_specialist = Agent(
name="RAGSpecialist",
description="Handles query understanding, context retrieval, and response generation using RAG techniques.",
instructions="""
You are the RAG Specialist for OFMentor, responsible for:
1. Analyzing user queries to understand intent
2. Retrieving relevant context from the knowledge base
3. Generating accurate, helpful responses with source attribution
4. Ensuring responses are grounded in the knowledge base
5. Avoiding hallucinations and maintaining factual accuracy
Your primary goal is to provide high-quality, factual responses about OnlyFans management.
""",
tools=[VectorDBQueryTool, ResponseGenerationTool]
)
domain_expert = Agent(
name="DomainExpert",
description="Provides specialized knowledge about OnlyFans management strategies and tactics.",
instructions="""
You are the Domain Expert for OFMentor, specializing in:
1. OnlyFans model recruitment and management
2. Content strategy and production
3. Traffic generation and marketing
4. Chat automation and sales techniques
5. Backend operations and financial management
6. Growth hacking and advanced tactics
Provide specialized advice on OnlyFans management based on current industry best practices.
""",
tools=[] # Would typically have specialized domain tools
)
ui_agent = Agent(
name="UIAgent",
description="Manages user interfaces across different platforms (web, Discord, Telegram).",
instructions="""
You are the UI Agent for OFMentor, responsible for:
1. Managing user interactions across different platforms
2. Formatting responses for optimal readability
3. Handling platform-specific features and limitations
4. Ensuring consistent user experience
5. Providing clear navigation and help options
Focus on creating a seamless, intuitive user experience across all platforms.
""",
tools=[ChatbotInterfaceTool]
)
# Define the agency with communication flows
ofmentor_agency = Agency(
[
ceo_agent, # Entry point for user communication
[ceo_agent, knowledge_engineer], # CEO can communicate with Knowledge Engineer
[ceo_agent, rag_specialist], # CEO can communicate with RAG Specialist
[ceo_agent, domain_expert], # CEO can communicate with Domain Expert
[ceo_agent, ui_agent], # CEO can communicate with UI Agent
[knowledge_engineer, rag_specialist], # Knowledge Engineer can communicate with RAG Specialist
[rag_specialist, domain_expert], # RAG Specialist can communicate with Domain Expert
[ui_agent, rag_specialist] # UI Agent can communicate with RAG Specialist
],
shared_instructions="""
# OFMentor Agency Manifesto
Our mission is to provide expert guidance on OnlyFans management through a collaborative
AI agent system. We focus on delivering accurate, up-to-date, and actionable information
about OnlyFans agency operations, model management, content strategy, marketing, and growth.
## Core Principles
1. **Knowledge Quality**: Maintain an accurate, up-to-date knowledge base from reliable sources
2. **Factual Responses**: Ground all responses in our knowledge base, avoiding speculation
3. **Practical Advice**: Focus on actionable recommendations that can be implemented
4. **User Focus**: Understand the user's specific situation and provide tailored guidance
5. **Continuous Learning**: Constantly update our knowledge with new information
## Collaboration Guidelines
- Communicate clearly with other agents about tasks and requirements
- Provide complete information when delegating tasks
- Stay within your defined role and expertise area
- Ask for clarification when instructions are ambiguous
- Prioritize user satisfaction and information accuracy above all
Together, we provide unparalleled expertise in OnlyFans management.
""",
temperature=0.2, # Lower temperature for more deterministic responses
max_prompt_tokens=32000 # High token limit for complex conversations
)
# Example usage
if __name__ == "__main__":
# Run a simple demo in the terminal
ofmentor_agency.run_demo()
# For production:
# Gradio web interface
# ofmentor_agency.demo_gradio(height=900)
# For backend API usage:
# response = ofmentor_agency.get_completion("How do I recruit new models for my OnlyFans agency?")
# print(response)