Spaces:
Runtime error
Runtime error
File size: 616 Bytes
e72aedf |
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 |
import os
from fastchat.model import get_conversation_template
def claude():
import anthropic
c = anthropic.Client(os.environ["ANTHROPIC_API_KEY"])
model = "claude-v1"
conv = get_conversation_template(model)
conv.append_message(conv.roles[0], "Hello!")
conv.append_message(conv.roles[1], None)
prompt = conv.get_prompt()
response = c.completion_stream(
prompt=prompt,
stop_sequences=[anthropic.HUMAN_PROMPT],
max_tokens_to_sample=256,
model=model,
stream=True,
)
for data in response:
print(data["completion"])
claude()
|