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

  • A community for building, creating, and growing with AI.

    Welcome to AI Forums, a community for people using AI to build products, automate workflows, create content, and grow businesses. Discuss vibe coding, AI agents, Claude Code, Codex, automation, AI tools, product launches, marketing, and the latest developments in AI.

    Join the Community (it's FREE)!

mr_meeseeks

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
 
Back
Top