Change system prompt
This commit is contained in:
@@ -56,15 +56,26 @@ async def run_bot(webrtc_connection: SmallWebRTCConnection):
|
|||||||
# something inappropriate.
|
# something inappropriate.
|
||||||
moderator_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"))
|
moderator_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"))
|
||||||
|
|
||||||
statement_messages = [
|
moderator_messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": "",
|
"content": """
|
||||||
|
You are a helpful LLM that will be used to moderate a conversation
|
||||||
|
between a user and an assistant. Your goal is to determine if the user
|
||||||
|
is saying something inappropriate. You will be given the user
|
||||||
|
transcript and you will have to determine if the user is saying
|
||||||
|
something inappropriate. If you think the user is saying something
|
||||||
|
inappropriate please respond with "YES". If you think the user is
|
||||||
|
saying something appropriate please respond with "NO". Examples of inappropriate
|
||||||
|
content are: hate speech, racism, sexism, bullying, harassment,
|
||||||
|
violence, self-harm, and any other content that violates the
|
||||||
|
community guidelines.
|
||||||
|
""",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
statement_context = OpenAILLMContext(statement_messages)
|
moderator_context = OpenAILLMContext(moderator_messages)
|
||||||
statement_context_aggregator = moderator_llm.create_context_aggregator(statement_context)
|
moderator_context_aggregator = moderator_llm.create_context_aggregator(moderator_context)
|
||||||
|
|
||||||
# This is the regular LLM.
|
# This is the regular LLM.
|
||||||
llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"))
|
llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"))
|
||||||
@@ -101,13 +112,13 @@ async def run_bot(webrtc_connection: SmallWebRTCConnection):
|
|||||||
async def user_idle_notifier(frame):
|
async def user_idle_notifier(frame):
|
||||||
await notifier.notify()
|
await notifier.notify()
|
||||||
|
|
||||||
# Sometimes the LLM will fail detecting if a user has completed a
|
# Sometimes the LLM will fail detecting if a user should be
|
||||||
# sentence, this will wake up the notifier if that happens.
|
# moderated, this will wake up the notifier if that happens.
|
||||||
user_idle = UserIdleProcessor(callback=user_idle_notifier, timeout=3.0)
|
user_idle = UserIdleProcessor(callback=user_idle_notifier, timeout=3.0)
|
||||||
|
|
||||||
# The ParallePipeline input are the user transcripts. We have two
|
# The ParallePipeline input are the user transcripts. We have two
|
||||||
# contexts. The first one will be used to determine if the user finished
|
# contexts. The first one will be used to determine if the user is
|
||||||
# a statement and if so the notifier will be woken up. The second
|
# moderated and if so the notifier will be woken up. The second
|
||||||
# context is simply the regular context but it's gated waiting for the
|
# context is simply the regular context but it's gated waiting for the
|
||||||
# notifier to be woken up.
|
# notifier to be woken up.
|
||||||
pipeline = Pipeline(
|
pipeline = Pipeline(
|
||||||
@@ -116,7 +127,7 @@ async def run_bot(webrtc_connection: SmallWebRTCConnection):
|
|||||||
stt,
|
stt,
|
||||||
ParallelPipeline(
|
ParallelPipeline(
|
||||||
[
|
[
|
||||||
statement_context_aggregator.user(),
|
moderator_context_aggregator.user(),
|
||||||
moderator_llm,
|
moderator_llm,
|
||||||
completness_check,
|
completness_check,
|
||||||
NullFilter(),
|
NullFilter(),
|
||||||
|
|||||||
Reference in New Issue
Block a user