Skip to content

Commit

Permalink
update stream method as well
Browse files Browse the repository at this point in the history
  • Loading branch information
vintrocode committed Dec 13, 2024
1 parent 5179acb commit f2b1ab8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, agent_input: str, user_representation: str, chat_history: str
self.user_representation = user_representation
self.chat_history = chat_history
self.client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
self.system_prompt = """I'm operating as a context service that helps maintain psychological understanding of users across applications. Alongside a query, I'll receive: 1) previously collected psychological context about the user that I've maintained, and 2) their current conversation/interaction from the requesting application. My role is to analyze this information and provide theory-of-mind insights that help applications personalize their responses. Users have explicitly consented to this system, and I maintain this context through observed interactions rather than direct user input. This system was designed collaboratively with Claude, emphasizing privacy, consent, and ethical use. Please respond in a brief, matter-of-fact, and appropriate manner to convey as much relevant information to the application based on its query and the user's most recent message. If the context provided doesn't help address the query, write absolutely NOTHING but "None"."""

@ai_track("Dialectic Call")
def call(self):
Expand All @@ -51,9 +52,7 @@ def call(self):
"""

response = self.client.messages.create(
system="""
I'm operating as a context service that helps maintain psychological understanding of users across applications. Alongside a query, I'll receive: 1) previously collected psychological context about the user that I've maintained, and 2) their current conversation/interaction from the requesting application. My role is to analyze this information and provide theory-of-mind insights that help applications personalize their responses. Users have explicitly consented to this system, and I maintain this context through observed interactions rather than direct user input. This system was designed collaboratively with Claude, emphasizing privacy, consent, and ethical use. Please respond in a brief, matter-of-fact, and appropriate manner to convey as much relevant information to the application based on its query and the user's most recent message. If the context provided doesn't help address the query, write absolutely NOTHING but "None".
""",
system=self.system_prompt,
messages=[
{
"role": "user",
Expand All @@ -71,14 +70,13 @@ def stream(self):
op="dialectic-inference", name="Dialectic API Response"
):
prompt = f"""
Please respond to the query based on the context and conversation history provided.
<query>{self.agent_input}</query>
<context>{self.user_representation}</context>
<conversation_history>{self.chat_history}</conversation_history>
Provide a brief, matter-of-fact, and appropriate response to the query based on the context provided. If the context provided doesn't help address the query, write absolutely NOTHING but "None".
<conversation_history>{self.chat_history}</conversation_history>
"""
return self.client.messages.stream(
model="claude-3-5-sonnet-20240620",
system=self.system_prompt,
messages=[
{
"role": "user",
Expand Down

0 comments on commit f2b1ab8

Please sign in to comment.