-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object of type SearchEngineType is not JSON serializable #282
Comments
Since you are using agents, you need to use AgentConfigSearchToolDefinition in the agent_config and not SearchToolDefinition. In the code base checkout the object AgentConfigSearchToolDefinition and use that and for future references, whenever you are using inbuilt tools in agent_config use AgentConfigTools as they are all present in the code already. |
Thank you for the answer and I changed my code for : But I still have the following error : Erreur Create Agent : Object of type SearchEngineType is not JSON serializable, any idea what I'm missing ? |
Can you send your stack trace and the code properly? Start to end |
Sure ! Initializing Ollama, checking connectivity to server... Listening on 0.0.0.0:5000 And there is my code : from llama_stack_client.lib.agents import * import os warnings.filterwarnings('ignore') load_dotenv('fichier.env') ## Initialize tiktoken tokenizertokenizer_path = "tokenizer.model" mergeable_ranks = load_tiktoken_bpe(tokenizer_path) special_tokens = [ tokenizer = tiktoken.Encoding( Define a list of colorscolors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white"] def colorize_tokens(text):
def count_tokens(text): class Agent:
web_search = AgentConfigToolSearchToolDefinition( async def run_main(host: str, port: int, stream: bool = True):
def main(host: str, port: int, stream: bool = True): if name == "main": |
Firstly its self.client.agents.sessions.create and self.client.agents.turns.create. You have written session and turn respectively in their place that could be causing an issue. Update that and let me know
|
Still the same error with your modification : Erreur Create Agent : Object of type SearchEngineType is not JSON serializable |
I am unable to solve this because I can't see where SearchEngineType is being used in this code |
Here : async def run_main(host: str, port: int, stream: bool = True):
|
You are using AgentConfigToolSearchToolDefinition and not SearchEngineType
This is its definition. SearchEngineType is a object which is Enum |
I've tried previously with SearchEngineType (check my first post) and I had the same error. |
So with this code I don't have the error anymore but I don't have the web search working either :
sampling_params = SamplingParams( websearch = [ Inside run_main functionasync def run_main(host: str, port: int, stream: bool = True):
|
Hi,
I try to use the bing search engine tool and I have the Object of type SearchEngineType is not JSON serializable error when executing the agent.create_agent(agent_config) line.
There is my code and I don't know what I'm missing that make this error happening, any help appreciated :
class Agent:
def init(self, host, port):
self.client = LlamaStackClient(base_url=f"http://{host}:{port}")
async def run_main(host: str, port: int, stream: bool = True):
agent_config = AgentConfig(
model="Llama3.2-3B-Instruct",
instructions="You are a helpful assistant and you answer in french concisely and precisely.",
sampling_params=SamplingParams(temperature=0.0, top_p=0.9),
enable_session_persistence=False,
tools=[
SearchToolDefinition(
engine=SearchEngineType.bing,
api_key=os.getenv("BING_SEARCH_API_KEY"),
)
],
tool_choice=ToolChoice.auto,
)
The text was updated successfully, but these errors were encountered: