A community to discuss AI, SaaS, GPTs, and more.

Welcome to AI Forums – the premier online community for AI enthusiasts! Explore discussions on AI tools, ChatGPT, GPTs, and AI in entrepreneurship. Connect, share insights, and stay updated with the latest in AI technology.


Join the Community (it's FREE)!

use claude 3 with only one line of code DiClaude3 livingrimoire skill

Member
Messages
3
adding the skill:
chobit.addSkill(DiClaude3())

Python:
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
 
Top