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