Skip to content

Commit

Permalink
improve prompt, update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
doodledood committed Nov 13, 2023
1 parent bedb4de commit f7f6162
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
10 changes: 8 additions & 2 deletions chatflock/composition_generators/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ def create_compose_chat_participants_system_prompt(self, chat: "Chat") -> str:
list=[
"Only individual participants can be given tools.",
"You must only choose a tool from the AVAILABLE PARTICIPANT TOOLS list.",
"A tools should be given to a participant only if it can help them achieve the goal.",
"A tools should be given to a participant only if it can help them fulfill their personal mission better.",
],
),
Section(
name="Correct Hierarchical Composition",
list=[
"If you add a team, make sure to add the team as a participant, and not its individual members."
],
),
],
Expand Down Expand Up @@ -361,7 +367,7 @@ def create_compose_chat_participants_first_human_prompt(
messages = chat.get_messages()
messages_list = [f"- {message.sender_name}: {message.content}" for message in messages]

available_tools_list = list(set(f'{x.name}: "{x.description}"' for x in participant_available_tools or []))
available_tools_list = list({f'{x.name}: "{x.description}"' for x in participant_available_tools or []})

active_participants = chat.get_active_participants()

Expand Down
9 changes: 9 additions & 0 deletions chatflock/participants/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ def create_system_message(self, chat: "Chat", relevant_docs: Sequence[Document])
]
),
),
Section(
name="Guidelines",
list=[
"Your personal mission is the most important thing to you. You should always "
"prioritize it.",
"If a chat goal is provided, you should still follow your personal mission but "
"in a way that helps the group achieve the chat goal.",
],
),
Section(
name="Rules",
list=[
Expand Down
6 changes: 3 additions & 3 deletions examples/automatic_hierarchical_chat_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import typer
from dotenv import load_dotenv
from halo import Halo
from langchain.llms.openai import OpenAI
from langchain.memory import ConversationSummaryBufferMemory

from chatflock.backing_stores import InMemoryChatDataBackingStore
Expand Down Expand Up @@ -52,8 +51,9 @@ def create_chat(**kwargs: Any) -> Chat:
initial_participants=[user],
)

# Not necessary in practice since initiation is done automatically when calling `initiate_chat_with_result`.
# However, this is needed to eagerly generate the composition. Default is lazy.
# It's not necessary in practice to manually call `initialize_chat` since initiation is done automatically
# when calling `initiate_chat_with_result`. However, this is needed to eagerly generate the composition.
# Default is lazy and will happen when the chat is initiated.
chat_conductor.initialize_chat(
chat=chat,
# Only relevant when passing in a composition generator
Expand Down

0 comments on commit f7f6162

Please sign in to comment.