1- # This plugin will act as an interactive ChatGPT . It has the option to save the last few messages,
2- # but note that each message save will incur a higher token usage when communitcating with OpenAI
3- # as each message is included in the query to OpenAI . Also note that messages sent by other
1+ # This plugin will act as an interactive Gemini . It has the option to save the last few messages,
2+ # but note that each message save will incur a higher token usage when communitcating with Gemini
3+ # as each message is included in the query to Gemini . Also note that messages sent by other
44# plugins are currently not being saved.
55#
66# You can specify a "history_timeout" if you only want the plugin to only remember messages within a
99#
1010# Sample setting:
1111#
12- # "shrimpgpt ": {
13- # "key": "your-openai -app-key",
14- # "trigger": "chatgpt :", # Only respond to direct questions
15- # "channel": "#chatgpt ", # Only monitor one specific channel
12+ # "shrimpgemini ": {
13+ # "key": "your-gemini -app-key",
14+ # "trigger": "gemini :", # Only respond to direct questions
15+ # "channel": "#gemini ", # Only monitor one specific channel
1616# "prompt": "You are an IRC bot. Users will post questions that you answer.",
17- # "model": "gpt-4o-mini ",
17+ # "model": "gemini-2.5-flash ",
1818# "max_tokens": 256,
1919# "temperature": 0.2,
2020# "max_history": 5, # Let the plugin "remember" the past 5 messages (including responses)
2626# If "channel" is not specified, the plugin will respond in every channel.
2727#
2828# Commands:
29- # * !gpt history reset
29+ # * !gemini history reset
3030# Will manually trigger a reset of any previous messages saved.
3131
3232import logging
3333import sys
3434import json
3535import plugin
3636
37- from utils import openai
37+ from utils import gemini
3838
3939DEFAULT_PROMPT = """You are an IRC bot. Users will post questions that you answer."""
40- DEFAULT_MODEL = "gpt-4o-mini "
40+ DEFAULT_MODEL = "gemini-2.5-flash "
4141
4242
43- class shrimpgpt (plugin .Plugin ):
43+ class shrimpgemini (plugin .Plugin ):
4444 def __init__ (self ):
45- plugin .Plugin .__init__ (self , "shrimpgpt " )
45+ plugin .Plugin .__init__ (self , "shrimpgemini " )
4646
4747 def started (self , settings ):
4848 s = json .loads (settings )
@@ -52,15 +52,15 @@ def started(self, settings):
5252 prompt = s ["prompt" ] if "prompt" in s else DEFAULT_PROMPT
5353 self .system_message = {"role" : "system" , "content" : prompt }
5454 self .model = s ["model" ] if "model" in s else DEFAULT_MODEL
55- self .max_tokens = int (s ["max_tokens" ]) if "max_tokens" in s else 256
55+ self .max_tokens = int (s ["max_tokens" ]) if "max_tokens" in s else 512
5656 self .temperature = int (s ["temperature" ]) if "temperature" in s else 0.2
5757 self .history = []
5858 self .max_history = int (s ["max_history" ]) if "max_history" in s else 5
5959 # Max number of seconds of inactivity before cleaning out the message history
6060 self .history_timeout = int (s ["history_timeout" ]) if "history_timeout" in s else 120
6161 self .update_count = 0
6262 logging .info (
63- "ShrimpGPT : Trigger: %s, channel: %s, model: %s, max_tokens: %i, temp: %i" ,
63+ "ShrimpGemini : Trigger: %s, channel: %s, model: %s, max_tokens: %i, temp: %i" ,
6464 self .trigger ,
6565 self .channel ,
6666 self .model ,
@@ -74,12 +74,12 @@ def update(self):
7474 self .update_count += 1
7575 # Reset history if update_count exceeds "update_count"
7676 if self .update_count >= self .history_timeout :
77- logging .info ("ShrimpGPT : Resetting history: []" )
77+ logging .info ("ShrimpGemini : Resetting history: []" )
7878 self .history = []
7979 self .update_count = 0
8080
8181 def reset_history (self , server , channel ):
82- logging .info ("ShrimpGPT : Manual history reset" )
82+ logging .info ("ShrimpGemini : Manual history reset" )
8383 self .history = []
8484 self .safe_privmsg (server , channel , "Reset!" )
8585
@@ -96,17 +96,17 @@ def respond_to_message(self, query, server, channel):
9696 message = {"role" : "user" , "content" : query }
9797 self .add_to_history (message )
9898 messages = [self .system_message ] + self .history
99- result = openai .get_response (
99+ result = gemini .get_response (
100100 self .key , messages , self .model , self .max_tokens , self .temperature
101101 )
102- self .add_to_history ({"role" : "assistant " , "content" : result })
102+ self .add_to_history ({"role" : "model " , "content" : result })
103103 self .safe_privmsg (server , channel , result )
104104
105105 def on_pubmsg (self , server , user , channel , message ):
106106 if self .channel and channel != self .channel :
107107 # Message is not in the specified channel
108108 return
109- if message .startswith ("!gpt history reset" ):
109+ if message .startswith ("!gemini history reset" ):
110110 self ._thread (self .reset_history , server , channel )
111111 return
112112 username = user .split ("!" , 1 )[0 ]
@@ -122,4 +122,4 @@ def on_pubmsg(self, server, user, channel, message):
122122
123123
124124if __name__ == "__main__" :
125- sys .exit (shrimpgpt .run ())
125+ sys .exit (shrimpgemini .run ())
0 commit comments