-
Notifications
You must be signed in to change notification settings - Fork 826
/
claude.py
36 lines (32 loc) · 895 Bytes
/
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
36
import time
import json
import random
import os
import slack
import argparse
import warnings
import anthropic
client = anthropic.Client(
"sk-ant-WqXB_mm8My-_VYnEqAj_p9XFtdyZ5-36a_YHABdTn_NabriJQI8k-J2_Ie3E9_pyfXdP_MEuXfXFbC5wt3LiOw"
)
def call_claude_completion(
prompt,
model="claude-instant-v1",
stop=None,
max_tokens=512,
):
claude_prompt = anthropic.HUMAN_PROMPT + prompt + anthropic.AI_PROMPT
print(claude_prompt)
prompt = [claude_prompt, claude_prompt, claude_prompt]
response = client.completion(
prompt=claude_prompt,
stop_sequences=[anthropic.HUMAN_PROMPT, anthropic.AI_PROMPT],
model=model,
max_tokens_to_sample=max_tokens,
temperature=0,
)
return response["completion"]
if __name__ == '__main__':
result = call_claude_completion('Give me the result of 1 + 1')
print(result)
exit(0)