File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
src/langchain_google_spanner Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 1515"""Cloud Spanner-based chat message history"""
1616from __future__ import annotations
1717
18- import json
1918from typing import List , Optional
2019
2120from google .cloud import spanner
2221from google .cloud .spanner_admin_database_v1 .types import DatabaseDialect # type: ignore
2322from google .cloud .spanner_v1 import param_types
2423from google .cloud .spanner_v1 .data_types import JsonObject
2524from langchain_core .chat_history import BaseChatMessageHistory
26- from langchain_core .messages import BaseMessage , message_to_dict , messages_from_dict
25+ from langchain_core .messages import BaseMessage , messages_from_dict
2726
2827OPERATION_TIMEOUT_SECONDS = 240
2928
@@ -70,7 +69,7 @@ def _verify_schema(self) -> None:
7069 table with valid schema.
7170 """
7271 # check table exists
73- column_names = []
72+ column_names = [] # type: List[str]
7473 with self .database .snapshot () as snapshot :
7574 results = snapshot .execute_sql (
7675 f"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE table_name = '{ self .table_name } '"
@@ -148,7 +147,7 @@ def messages(self) -> List[BaseMessage]: # type: ignore
148147 params = param ,
149148 param_types = param_type ,
150149 )
151- items = []
150+ items = [] # type: List[dict]
152151 for row in results :
153152 items .append ({"data" : row [0 ], "type" : row [0 ]["type" ]})
154153 messages = messages_from_dict (items )
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+
1516import os
17+
1618import pytest # noqa
1719from google .cloud .spanner import Client # type: ignore
1820from langchain_core .messages .ai import AIMessage
2224
2325project_id = os .environ ["PROJECT_ID" ]
2426instance_id = os .environ ["INSTANCE_ID" ]
25- table_name = os .environ ["TABLE_NAME" ]
27+ table_name = os .environ ["TABLE_NAME" ]. replace ( "-" , "_" )
2628
2729OPERATION_TIMEOUT_SECONDS = 240
2830
You can’t perform that action at this time.
0 commit comments