Skip to content

Commit

Permalink
Merge pull request #12 from camel-ai/twitter_simu
Browse files Browse the repository at this point in the history
Twitter simu
  • Loading branch information
yiyiyi0817 authored Dec 4, 2024
2 parents 15d2f96 + cd4d39e commit e0d4d6b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions oasis/social_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(
"What do you think Helen should do?")

async def perform_action_by_llm(self):
# Get 5 random tweets:
# Get posts:
env_prompt = await self.env.to_text_prompt()
user_msg = BaseMessage.make_user_message(
role_name="User",
Expand All @@ -128,6 +128,13 @@ async def perform_action_by_llm(self):

openai_messages, _ = self.memory.get_context()
content = ""
# sometimes self.memory.get_context() would lose system prompt
start_message = openai_messages[0]
if start_message["role"] != self.system_message.role_name:
openai_messages = [{
"role": self.system_message.role_name,
"content": self.system_message.content,
}] + openai_messages

if not openai_messages:
openai_messages = [{
Expand Down Expand Up @@ -158,12 +165,6 @@ async def perform_action_by_llm(self):
exec_functions = []

while retry > 0:
start_message = openai_messages[0]
if start_message["role"] != self.system_message.role_name:
openai_messages = [{
"role": self.system_message.role_name,
"content": self.system_message.content,
}] + openai_messages

mes_id = await self.infe_channel.write_to_receive_queue(
openai_messages)
Expand Down

0 comments on commit e0d4d6b

Please sign in to comment.