chat.py 440 B

123456789101112131415161718192021
  1. from dotenv import load_dotenv
  2. import os
  3. import cohere
  4. # configuration
  5. load_dotenv()
  6. secret_key = os.getenv("API_KEY")
  7. co = cohere.Client(secret_key)
  8. def genActivity(topic):
  9. response = co.generate(
  10. model='command',
  11. prompt=topic,
  12. max_tokens=300,
  13. temperature=0.3,
  14. )
  15. # response is a string that is the answer to the topic in less than 60 words
  16. return response.generations[0].text
  17. # print(genActivity(topic))