adding the skill:
chobit.addSkill(DiClaude3())
chobit.addSkill(DiClaude3())
Code:
class DiClaude3(DiSkillV2):
def __init__(self):
super().__init__()
self._apikey: str = ""
with open('claude3_apikey.txt', 'r') as f:
self._apikey = f.read()
self.dialog: AXCmdBreaker = AXCmdBreaker("over")
self._err = False
def input(self, ear: str, skin: str, eye: str):
if len(ear) == 0 or self._err:
return
try:
temp = self.dialog.extractCmdParam(ear)
if temp:
self.setSimpleAlg(self.get_claude_reply(temp))
except:
self._err = True
def get_claude_reply(self, prompt: str) -> str:
"""
Get a string reply from Claude 3 using the provided prompt.
Args:
prompt (str): The user's input prompt.
Returns:
str: The response generated by Claude 3.
"""
client = anthropic.Anthropic(api_key=self._apikey)
message = client.messages.create(
model="claude-3-opus-20240229", # Use the desired model
max_tokens=1000,
temperature=0.0,
system="you are a chobit named potato, keep replies under 50 characters, never end replies with a question",
messages=[{"role": "user", "content": prompt}]
)
return message.content[0].text