You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm facing an issue where the bot does not use any tools from pydantic_ai. Specifically, the bot should return a True or False response through the selection function, but it's not working with gpt4free. However, when I switch to GeminiModel (from pydantic_ai.models.gemini import GeminiModel), it works as expected. I'd like the bot to correctly call and use the selection tool from pydantic_ai so that the boolean response is accurately reflected.
Describe the solution you'd like
I want the bot to consistently utilize the selection function within pydantic_ai (i.e., selection(bool(False)) or selection(bool(True))) regardless of which model is used. Essentially, the response should explicitly be False or True based on the filter logic, matching the code’s intention.
Describe alternatives you've considered
Switching to GeminiModel from pydantic_ai.models.gemini does resolve the issue, but I would prefer to use gpt4free for my setup.
Manually forcing the bot to return a hardcoded False or True value is a temporary workaround, but it defeats the purpose of using the agent’s logic.
I have tried multiple models offered by gpt4free, but the result remains the same (the selection function is not invoked).
Additional context
Below is the relevant code snippet demonstrating the issue. The selection function is not called when using gpt4free, resulting in Selection call: None and an incorrect agent result:
frompydantic_aiimportAgent, Toolfromg4f.tools.pydantic_aiimportAIModelclassVacancyBot:
def__init__(self):
self.model=AIModel("gpt-4o-mini")
self.agent_selection=Noneself.agent_result=Noneself.filter_phrase=Nonedefinit_agent(self):
self.agent=Agent(
self.model,
system_prompt=(
'You will be sent descriptions of the vacancies, your task is to accept or reject the vacancies with the help of `selection` tool, you should make conclusions to accept or reject the vacancy strictly according to the filter phrase.''BE SURE TO USE A TOOL!'f'Filter phrase: {self.filter_phrase}'
),
tools=[
Tool(self.selection),
]
)
defselection(self, boolean: bool) ->bool:
''' accept or reject the vacancy example reject vacancy: selection(bool(False)) '''self.agent_selection=booleanreturnbooleandefset_filter_phrase(self, phrase):
self.filter_phrase=phraseasyncdefrun_bot(self, msg):
result=awaitself.agent.run(msg)
self.agent_result=result.datadefshow_selection(self):
print("Selection call:", self.agent_selection)
defshow_agent_result(self):
print("Agent result:", self.agent_result)
if__name__=='__main__':
importasynciobot=VacancyBot()
msg="you will write programs in Rust"bot.set_filter_phrase('reject jobs related to python development, accept all others.')
bot.init_agent()
asyncio.run(bot.run_bot(msg))
bot.show_selection()
bot.show_agent_result()
With GeminiModel, the bot correctly responds with a boolean value, but with gpt4free, the Selection call remains None and the agent result is incorrect. Any guidance or fix for this behavior would be greatly appreciated.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I'm facing an issue where the bot does not use any tools from
pydantic_ai
. Specifically, the bot should return aTrue
orFalse
response through theselection
function, but it's not working withgpt4free
. However, when I switch toGeminiModel
(from pydantic_ai.models.gemini import GeminiModel
), it works as expected. I'd like the bot to correctly call and use theselection
tool frompydantic_ai
so that the boolean response is accurately reflected.Describe the solution you'd like
I want the bot to consistently utilize the
selection
function withinpydantic_ai
(i.e.,selection(bool(False))
orselection(bool(True))
) regardless of which model is used. Essentially, the response should explicitly beFalse
orTrue
based on the filter logic, matching the code’s intention.Describe alternatives you've considered
GeminiModel
frompydantic_ai.models.gemini
does resolve the issue, but I would prefer to usegpt4free
for my setup.False
orTrue
value is a temporary workaround, but it defeats the purpose of using the agent’s logic.gpt4free
, but the result remains the same (theselection
function is not invoked).Additional context
Below is the relevant code snippet demonstrating the issue. The
selection
function is not called when usinggpt4free
, resulting inSelection call: None
and an incorrect agent result:With GeminiModel, the bot correctly responds with a boolean value, but with gpt4free, the Selection call remains None and the agent result is incorrect. Any guidance or fix for this behavior would be greatly appreciated.
The text was updated successfully, but these errors were encountered: