diff --git a/README.md b/README.md index f7251fe..00be403 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ $ cp example-chat.conf chat.conf ### Configuration: Edit chat.conf and change variables. Example configuration for IRCNet: + +**There is a new variable "context", it's optional: you can leave it blank or enter what you want the bot to know and how you want the bot to behave.** + +**e.g.: You are an ironic and arrogant bot on the #linux channel, James and Mark are on the channel with you. James loves to play guitar and Mark is a footballer. You speak Scottish slang.** ``` [openai] api_key = sk-XXXXXXXXXXXXXXX @@ -27,6 +31,7 @@ api_key = sk-XXXXXXXXXXXXXXX [chatcompletion] model = gpt-3.5-turbo role = user +context = You are a helpful and friendly bot on IRC channel #linux. temperature = 0.8 max_tokens = 1000 top_p = 1 diff --git a/chatgpt.py b/chatgpt.py index 6b76a0b..f2a1b30 100644 --- a/chatgpt.py +++ b/chatgpt.py @@ -22,6 +22,7 @@ top_p = config.getint('chatcompletion', 'top_p') frequency_penalty = config.getint('chatcompletion', 'frequency_penalty') presence_penalty = config.getint('chatcompletion', 'presence_penalty') request_timeout = config.getint('chatcompletion', 'request_timeout') +context = config.get('chatcompletion', 'context') # Set up IRC connection settings server = config.get('irc', 'server') @@ -102,7 +103,7 @@ while True: try: response = openai.ChatCompletion.create( model=model, - messages=[{"role": role, "content": question}], + messages=[{"role": "system", "content": context}, {"role": "user", "content": question}], temperature=temperature, max_tokens=max_tokens, top_p=top_p, diff --git a/example-chat.conf b/example-chat.conf index cd3c0d3..2e06d13 100644 --- a/example-chat.conf +++ b/example-chat.conf @@ -4,6 +4,7 @@ api_key = sk-XXXXXXXXXXXXXXX [chatcompletion] model = gpt-3.5-turbo role = user +context = You are helpful and friendly bot on IRC channel #linux. temperature = 0.8 max_tokens = 1000 top_p = 1 @@ -15,7 +16,7 @@ request_timeout = 60 server = open.ircnet.net port = 6667 ssl = false -channels = #knrd1,#github +channels = #linux,#github nickname = MyBot ident = mybot realname = My Bot