-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClaude.py
35 lines (31 loc) · 1.02 KB
/
Claude.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
from LLM import LLM
import torch
from openai import AzureOpenAI
import json
from datetime import datetime
import anthropic
class Claude(LLM):
def load_model(self):
self.id = 18
self.model = anthropic.Anthropic()
def generate(self, prompt: str) -> str:
messages = [
# {
# "role": "system",
# "content": "You are an AI assistant that answers Place related MCQ questions."
# },
{
"role": "user",
"content": prompt,
},
]
message = self.model.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=512,
temperature=0,
system="You are an AI assistant that answers Place related MCQ questions.",
messages=messages
)
print(message.content[0].text)
return message.content[0].text