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
I was trying to test the SingleStore Persistent Storage but the code throws an error after the thinking process.
from phi.storage.agent.singlestore import S2AgentStorage
from dotenv import load_dotenv
from phi.model.google import Gemini
from phi.agent import Agent, RunResponse
from sqlalchemy import create_engine
import os
load_dotenv()
# SingleStore Configuration
USERNAME = os.getenv("SINGLESTORE_USERNAME")
PASSWORD = os.getenv("SINGLESTORE_PASSWORD")
HOST = os.getenv("SINGLESTORE_HOST")
PORT = os.getenv("SINGLESTORE_PORT")
DATABASE = os.getenv("SINGLESTORE_DATABASE")
SSL_CERT = os.getenv("SINGLESTORE_SSL_CERT", None)
# SingleStore DB URL
db_url = f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"
if SSL_CERT:
db_url += f"&ssl_ca={SSL_CERT}&ssl_verify_cert=true"
# Create a database engine
db_engine = create_engine(db_url)
# Create a storage backend using the Singlestore database
storage = S2AgentStorage(
# store sessions in the ai.sessions table
table_name="agent_sessions",
# db_engine: Singlestore database engine
db_engine=db_engine,
# schema: Singlestore schema
schema=DATABASE,
)
# Add storage to the Agent
agent = Agent(
model=Gemini(id="gemini-1.5-flash"),
storage=storage,
add_history_to_messages=True,
num_history_responses=5,
description="You are a general purpose agent.",
markdown=True,
)
agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")
agent.print_response("Which country are we speaking about?")
Code referred from phidata Docs.
Error
▰▰▰▰▱▱▱ Thinking...
Traceback (most recent call last):
File "C:\Users\petro\AppData\Local\pypoetry\Cache\virtualenvs\version3-3qoseo5I-py3.12\Lib\site-packages\phi\storage\agent\singlestore.py", line 204, in upsert
"memory": json.dumps(session.memory, ensure_ascii=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\encoder.py",
line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\encoder.py",
line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\encoder.py",
line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type RepeatedComposite is not JSON serializable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\ML\Egenie\egenie-chatbot\version3\version3\test.py", line 50, in <module>
agent.print_response("How many people live in Canada?")
File "C:\Users\petro\AppData\Local\pypoetry\Cache\virtualenvs\version3-3qoseo5I-py3.12\Lib\site-packages\phi\agent\agent.py", line 2904, in print_response
run_response = self.run(message=message, messages=messages, stream=False, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\pypoetry\Cache\virtualenvs\version3-3qoseo5I-py3.12\Lib\site-packages\phi\agent\agent.py", line 2070, in run
return next(resp)
^^^^^^^^^^
File "C:\Users\petro\AppData\Local\pypoetry\Cache\virtualenvs\version3-3qoseo5I-py3.12\Lib\site-packages\phi\agent\agent.py", line 1922, in _run
self.write_to_storage()
File "C:\Users\petro\AppData\Local\pypoetry\Cache\virtualenvs\version3-3qoseo5I-py3.12\Lib\site-packages\phi\agent\agent.py", line 749, in write_to_storage
self._agent_session = self.storage.upsert(session=self.get_agent_session())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\pypoetry\Cache\virtualenvs\version3-3qoseo5I-py3.12\Lib\site-packages\phi\storage\agent\singlestore.py", line 227, in upsert
"memory": json.dumps(session.memory, ensure_ascii=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\encoder.py",
line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\encoder.py",
line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "C:\Users\petro\AppData\Local\Programs\Python\Python312\Lib\json\encoder.py",
line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type RepeatedComposite is not JSON serializable
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1735829064.935814 16056 init.cc:229] grpc_wait_for_shutdown_with_timeout() timed out.
I would appreciate any help.
The text was updated successfully, but these errors were encountered:
Hey @sahill3
Thank you for using Phidata and bringing this to our attention!
The team has been looking into the issue and we were able to reproduce your findings. The core of the issue lies in the Gemini responses and that they contain certain protobuf objects like the RepeatedComposite that are not easily accepted into mysql.
Do you at the moment have a hard requirement to use Gemini and SingleStore?
Could you consider using the postgres storage option or perhaps another model in the meantime? The team has an open ticket to address this properly within the next two weeks.
Hey @sahill3 Thank you for using Phidata and bringing this to our attention! The team has been looking into the issue and we were able to reproduce your findings. The core of the issue lies in the Gemini responses and that they contain certain protobuf objects like the RepeatedComposite that are not easily accepted into mysql. Do you at the moment have a hard requirement to use Gemini and SingleStore? Could you consider using the postgres storage option or perhaps another model in the meantime? The team has an open ticket to address this properly within the next two weeks.
I was trying to test the SingleStore Persistent Storage but the code throws an error after the thinking process.
Code referred from phidata Docs.
Error
I would appreciate any help.
The text was updated successfully, but these errors were encountered: