Skip to content

Commit

Permalink
Use claude prompt structure
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonBohdan committed Dec 4, 2023
1 parent 6978844 commit 6e1a860
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions neon_llm_claude/claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,20 @@ def _assemble_prompt(self, message: str, chat_history: List[List[str]], persona:
"""
Assembles prompt engineering logic
Setup Guidance:
https://platform.openai.com/docs/guides/gpt/chat-completions-api
https://docs.anthropic.com/claude/docs/introduction-to-prompt-design
:param message: Incoming prompt
:param chat_history: History of preceding conversation
:returns: assembled prompt
"""
system_prompt = persona.get("description", self._system_prompt)
messages = [
{"role": "system", "content": system_prompt},
]
prompt = system_prompt
# Context N messages
for role, content in chat_history[-self.context_depth:]:
role_claude = self.convert_role(role)
messages.append({"role": role_claude, "content": content})
messages.append({"role": "user", "content": message})
return messages
prompt += f"{role_claude} {content}"
prompt += f"{self.convert_role('user')} {message}"
return prompt

def _score(self, prompt: str, targets: List[str], persona: dict) -> List[float]:
"""
Expand Down

0 comments on commit 6e1a860

Please sign in to comment.