Repository navigation
Expand file tree
/
Copy pathclaude_cli.py
More file actions
62 lines (51 loc) · 1.48 KB
/
Copy pathclaude_cli.py
File metadata and controls
62 lines (51 loc) · 1.48 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
""" import os
import sys
import anthropic
api_key = os.getenv("ANTHROPIC_API_KEY")
if not api_key:
raise SystemExit("Missing ANTHROPIC_API_KEY. Set it with: export ANTHROPIC_API_KEY='sk-ant-...'")
client = anthropic.Anthropic(api_key=api_key)
prompt = " ".join(sys.argv[1:]) or "Say hello from Codespaces"
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=300,
messages=[{"role": "user", "content": prompt}],
)
print(resp.content[0].text) """
import os
import sys
import anthropic
api_key = os.getenv("ANTHROPIC_API_KEY")
client = anthropic.Anthropic(api_key=api_key)
# Load your paper once
with open("Paper.pdf", "rb") as f:
paper_bytes = f.read()
prompt = " ".join(sys.argv[1:])
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=800,
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "This is my KEVGraph research paper. Understand it deeply and reason from it."
},
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": paper_bytes
}
},
{
"type": "text",
"text": prompt
}
]
}
],
)
print(resp.content[0].text)