伊地知ニジカ放送局だぬ゛ん゛. https://www.youtube.com/@deerjika
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

talk.py 1.4 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
123456789101112131415161718192021222324252627282930313233343536
  1. import sys
  2. import openai
  3. from openai.types import *
  4. from connection import *
  5. class Talk:
  6. DUMMY_RESPONSE: str = 'あいうえおかきくけこさしすせそたちつてとなにぬねの'
  7. max_tokens_count: int = 100
  8. responses_count: int = 1
  9. temperature: float = .7
  10. top_p: int = 1
  11. @classmethod
  12. def main (cls, message: str) -> str:
  13. openai.organization = OPENAI_ORGANISATION
  14. openai.api_key = OPENAI_API_KEY
  15. return cls.__get_message (message).content
  16. @classmethod
  17. def __get_message (cls, message: str) \
  18. -> chat.chat_completion_message.ChatCompletionMessage:
  19. return openai.chat.completions.create (
  20. model = 'gpt-3.5-turbo',
  21. messages = [{'role': 'system',
  22. 'content': 'あなたの名前は伊地知ニジカ。友達はゴートうひとりとラマ田リョウ。好きな人は喜多ちゃん。すべての語尾に「ぬ゛ん」か「だぬ゛ん」をつけて質問に短く答えろ。定期的に「ぬ゛ぅ゛ぅ゛ぅ゛ぅ゛ん゛」、「ボッチチャーン」、「あっ」のいずれかを発しろ'},
  23. {'role': 'user',
  24. 'content': message}]).choices[0].message
  25. if __name__ == '__main__':
  26. print (Talk.main (sys.argv[1] if len (sys.argv) > 1 else ''))