Skip to content

Commit

Permalink
Format Python code with psf/black push
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and github-actions committed Nov 22, 2023
1 parent b3024ff commit 4920720
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 17 deletions.
7 changes: 6 additions & 1 deletion cogs/code_interpreter_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,12 @@ async def code_interpreter_chat_command(
)
)

llm = ChatOpenAI(model=model, temperature=temperature, top_p=top_p, openai_api_key=OPENAI_API_KEY)
llm = ChatOpenAI(
model=model,
temperature=temperature,
top_p=top_p,
openai_api_key=OPENAI_API_KEY,
)

max_token_limit = 29000 if "gpt-4" in model else 7500

Expand Down
24 changes: 15 additions & 9 deletions cogs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ async def load_index(
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=0
default=0,
)
@discord.option(
name="top_p",
Expand All @@ -770,7 +770,7 @@ async def load_index(
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=1
default=1,
)
async def talk(
self,
Expand Down Expand Up @@ -1137,7 +1137,7 @@ async def draw_action(self, ctx, message: discord.Message):
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=0
default=0,
)
@discord.option(
name="top_p",
Expand All @@ -1146,7 +1146,7 @@ async def draw_action(self, ctx, message: discord.Message):
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=1
default=1,
)
async def chat_code(
self,
Expand All @@ -1160,7 +1160,9 @@ async def chat_code(
"Code interpretation is disabled on this server.", ephemeral=True
)
return
await self.code_interpreter_cog.code_interpreter_chat_command(ctx, model=model, temperature=temperature, top_p=top_p)
await self.code_interpreter_cog.code_interpreter_chat_command(
ctx, model=model, temperature=temperature, top_p=top_p
)

"""
Translation commands and actions
Expand Down Expand Up @@ -1284,7 +1286,7 @@ async def summarize_action(self, ctx, message: discord.Message):
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=0
default=0,
)
@discord.option(
name="top_p",
Expand All @@ -1293,7 +1295,7 @@ async def summarize_action(self, ctx, message: discord.Message):
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=1
default=1,
)
async def chat(
self,
Expand All @@ -1304,7 +1306,11 @@ async def chat(
top_p: float = 1,
):
await self.search_cog.search_chat_command(
ctx, search_scope=search_scope, model=model, temperature=temperature, top_p=top_p,
ctx,
search_scope=search_scope,
model=model,
temperature=temperature,
top_p=top_p,
)

# Search slash commands
Expand Down Expand Up @@ -1371,7 +1377,7 @@ async def search(
nodes: int = 4,
deep: bool = False,
response_mode: str = "refine",
model: str ="gpt-4-1106-preview",
model: str = "gpt-4-1106-preview",
multistep: bool = False,
):
await self.search_cog.search_command(
Expand Down
3 changes: 2 additions & 1 deletion cogs/index_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ async def on_message(self, message):

prompt += (
"\n{System Message: the user has just uploaded the file "
+ str(file.filename) + "\n"
+ str(file.filename)
+ "\n"
)

# Link operations, allow for user link upload, we connect and download the content at the link.
Expand Down
14 changes: 12 additions & 2 deletions cogs/search_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,12 @@ async def on_message(self, message):
safe_remove_list(self.thread_awaiting_responses, message.channel.id)

async def search_chat_command(
self, ctx: discord.ApplicationContext, model, search_scope=2, temperature=0, top_p=1,
self,
ctx: discord.ApplicationContext,
model,
search_scope=2,
temperature=0,
top_p=1,
):
await ctx.defer()
embed_title = f"{ctx.user.name}'s internet-connected conversation with GPT"
Expand Down Expand Up @@ -477,7 +482,12 @@ async def search_chat_command(
traceback.print_exc()
print("Wolfram tool not added to internet-connected conversation agent.")

llm = ChatOpenAI(model=model, temperature=temperature, top_p=top_p, openai_api_key=OPENAI_API_KEY)
llm = ChatOpenAI(
model=model,
temperature=temperature,
top_p=top_p,
openai_api_key=OPENAI_API_KEY,
)

max_token_limit = 29000 if "gpt-4" in model else 7500

Expand Down
8 changes: 6 additions & 2 deletions models/index_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,12 @@ async def start_index_chat(self, ctx, model, temperature, top_p):
preparation_message = await ctx.channel.send(
embed=EmbedStatics.get_index_chat_preparation_message()
)
llm = ChatOpenAI(model=model, temperature=temperature, top_p=top_p, max_retries=2)
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=temperature, top_p=top_p, model_name=model))
llm = ChatOpenAI(
model=model, temperature=temperature, top_p=top_p, max_retries=2
)
llm_predictor = LLMPredictor(
llm=ChatOpenAI(temperature=temperature, top_p=top_p, model_name=model)
)

max_token_limit = 29000 if "gpt-4" in model else 7500

Expand Down
5 changes: 3 additions & 2 deletions models/search_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ async def search(
os.environ["OPENAI_API_KEY"] = user_api_key
openai.api_key = os.environ["OPENAI_API_KEY"]


# Initialize the search cost
price = 0

Expand Down Expand Up @@ -340,7 +339,9 @@ async def search(
embedding_model = OpenAIEmbedding()

if "vision" in model:
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model=model, max_tokens=4096))
llm_predictor = LLMPredictor(
llm=ChatOpenAI(temperature=0, model=model, max_tokens=4096)
)
else:
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model=model))

Expand Down

0 comments on commit 4920720

Please sign in to comment.