Skip to content

Commit

Permalink
feat: gpt-3.5 supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Zero6992 committed Mar 25, 2024
1 parent fb7eeff commit 6ec3831
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/aclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from src import personas
from src.log import logger
from utils.message_utils import send_split_message, send_response_with_images
from utils.message_utils import send_split_message

from dotenv import load_dotenv
from discord import app_commands
Expand All @@ -14,6 +14,7 @@
from g4f.client import Client
from g4f.stubs import ChatCompletion
from g4f.Provider import RetryProvider, OpenaiChat, Bing, You
from g4f.Provider import FreeGpt, ChatgptNext, AItianhuSpace

g4f.debug.logging = True

Expand All @@ -26,9 +27,9 @@ def __init__(self) -> None:
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
self.chatBot = Client(
provider = RetryProvider([You, Bing, OpenaiChat], shuffle=False),
provider = RetryProvider([FreeGpt, ChatgptNext, AItianhuSpace, OpenaiChat, Bing, You], shuffle=False),
)
self.chatModel = 'gpt-4'
self.chatModel = os.getenv("MODEL")
self.conversation_history = []
self.current_channel = None
self.activity = discord.Activity(type=discord.ActivityType.listening, name="/chat | /help")
Expand Down
12 changes: 9 additions & 3 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import asyncio
import discord
from src.log import logger
from random import randrange

from g4f.client import Client
from g4f.Provider import RetryProvider, OpenaiChat, FreeChatgpt, Gemini, Liaobots, Bing, Gemini
from g4f.Provider import (RetryProvider, FreeGpt, ChatgptNext, AItianhuSpace,
You, OpenaiChat, FreeChatgpt, Liaobots,
Gemini, Bing)

from src.aclient import discordClient
from discord import app_commands
Expand Down Expand Up @@ -88,6 +89,7 @@ async def replyall(interaction: discord.Interaction):
@app_commands.choices(model=[
app_commands.Choice(name="gemeni", value="gemeni"),
app_commands.Choice(name="gpt-4", value="gpt-4"),
app_commands.Choice(name="gpt-3.5-turbo", value="gpt-3.5-turbo"),
])
async def chat_model(interaction: discord.Interaction, model: app_commands.Choice[str]):
await interaction.response.defer(ephemeral=True)
Expand All @@ -98,7 +100,11 @@ async def chat_model(interaction: discord.Interaction, model: app_commands.Choic
discordClient.chatModel = model.value
elif model.value == "gpt-4":
discordClient.reset_conversation_history()
discordClient.chatBot = Client(provider=RetryProvider([Liaobots, OpenaiChat, Bing], shuffle=False))
discordClient.chatBot = Client(provider=RetryProvider([Liaobots, You, OpenaiChat, Bing], shuffle=False))
discordClient.chatModel = model.value
elif model.value == "gpt-3.5-turbo":
discordClient.reset_conversation_history()
discordClient.chatBot = Client(provider=RetryProvider([FreeGpt, ChatgptNext, AItianhuSpace], shuffle=False))
discordClient.chatModel = model.value

await interaction.followup.send(f"> **INFO: Chat model switched to {model.name}.**")
Expand Down

0 comments on commit 6ec3831

Please sign in to comment.