| 54 | time.sleep(10) |
| 55 | |
| 56 | class AnthropicModel(): |
| 57 | def __init__(self, model_name="claude-2") -> None: |
| 58 | self.model_name = model_name |
| 59 | |
| 60 | self.anthropic = Anthropic( |
| 61 | api_key=ANTHROPIC_API_KEY, |
| 62 | ) |
| 63 | |
| 64 | def __call__(self, msg, **kwargs): |
| 65 | while True: |
| 66 | try: |
| 67 | completion = self.anthropic.completions.create( |
| 68 | model=self.model_name, |
| 69 | prompt=f"{HUMAN_PROMPT} {msg} {AI_PROMPT}", |
| 70 | **kwargs |
| 71 | ) |
| 72 | return completion.completion |
| 73 | |
| 74 | except: |
| 75 | pass |
| 76 | |
| 77 | time.sleep(10) |
| 78 | |
| 79 | def load_prompts(instruction, instructions_path): |
| 80 | if instruction is not None: |