Skip to content

Instantly share code, notes, and snippets.

@wooparadog
Created November 24, 2023 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wooparadog/f2f9efedb1257a05d0adb379a69e9216 to your computer and use it in GitHub Desktop.
Save wooparadog/f2f9efedb1257a05d0adb379a69e9216 to your computer and use it in GitHub Desktop.
import asyncio
from anthropic import AI_PROMPT, HUMAN_PROMPT, AsyncAnthropic
anthropic = AsyncAnthropic()
async def run(i):
print(f"!!!!!{i}!!!!!!!")
completion = await anthropic.completions.create(
model="claude-2.1",
max_tokens_to_sample=1000,
temperature=0,
prompt=f"你好${HUMAN_PROMPT} 今天天气怎么样${AI_PROMPT} 对不起,我没有访问实时天气信息的能力。我是 Claude,一个 AI 助手。${HUMAN_PROMPT} 你是谁?${AI_PROMPT} 我是 Claude,一个由 Anthropic 公司开发的 AI 聊天助手。${HUMAN_PROMPT}${AI_PROMPT}",
)
print(completion.completion)
async def main():
await asyncio.gather(*[run(i) for i in range(10)])
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment