fix: Enhance generation configuration by adding system_instruction, tools, and tool_config
This commit is contained in:
parent
2db6b0f850
commit
04bbc056d2
@ -382,12 +382,18 @@ class TetoCog(commands.Cog):
|
||||
# `genai_client.aio.models.generate_content` does not directly take system_instruction.
|
||||
# It's better to pass system_instruction within the generation_config.
|
||||
|
||||
# Add system_instruction to generation_config
|
||||
# Add system_instruction, tools, and tool_config to generation_config
|
||||
generation_config_with_system = types.GenerateContentConfig(
|
||||
temperature=generation_config.temperature,
|
||||
max_output_tokens=generation_config.max_output_tokens,
|
||||
safety_settings=generation_config.safety_settings,
|
||||
system_instruction=types.Content(role="system", parts=[types.Part(text=system_prompt_text)])
|
||||
system_instruction=types.Content(role="system", parts=[types.Part(text=system_prompt_text)]),
|
||||
tools=vertex_tools, # Add tools here
|
||||
tool_config=types.ToolConfig( # Add tool_config here
|
||||
function_calling_config=types.FunctionCallingConfig(
|
||||
mode=types.FunctionCallingConfigMode.ANY if vertex_tools else types.FunctionCallingConfigMode.NONE
|
||||
)
|
||||
) if vertex_tools else None,
|
||||
)
|
||||
|
||||
final_contents_for_api = vertex_contents
|
||||
@ -398,12 +404,6 @@ class TetoCog(commands.Cog):
|
||||
model=f"projects/{PROJECT_ID}/locations/{LOCATION}/models/{self._ai_model}", # Full model path
|
||||
contents=final_contents_for_api,
|
||||
config=generation_config_with_system, # Pass the updated config
|
||||
tools=vertex_tools,
|
||||
tool_config=types.ToolConfig(
|
||||
function_calling_config=types.FunctionCallingConfig(
|
||||
mode=types.FunctionCallingConfigMode.ANY if vertex_tools else types.FunctionCallingConfigMode.NONE
|
||||
)
|
||||
) if vertex_tools else None,
|
||||
)
|
||||
|
||||
except google_exceptions.GoogleAPICallError as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user