Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjialin authored and fengjialin committed Mar 6, 2024
1 parent 0541ff4 commit a003ed0
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions libs/community/langchain_community/vectorstores/baiduvectordb.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,30 @@ def _create_table(self, table_name: str) -> None:
efconstruction=self.table_params.params.get("efConstruction", 200),
)
fields = []
fields.append(schema.Field(self.field_id, self.mochowenum.FieldType.STRING, primary_key=True,
partition_key=True, auto_increment=False, not_null=True))
fields.append(schema.Field(self.field_vector, self.mochowenum.FieldType.FLOAT_VECTOR,
dimension=self.table_params.dimension))
fields.append(
schema.Field(
self.field_id,
self.mochowenum.FieldType.STRING,
primary_key=True,
partition_key=True,
auto_increment=False,
not_null=True
)
)
fields.append(
schema.Field(
self.field_vector,
self.mochowenum.FieldType.FLOAT_VECTOR,
dimension=self.table_params.dimension
)
)
fields.append(schema.Field(self.field_text, self.mochowenum.FieldType.STRING))
fields.append(schema.Field(self.field_metadata, self.mochowenum.FieldType.STRING))
fields.append(
schema.Field(
self.field_metadata,
self.mochowenum.FieldType.STRING
)
)
indexes = []
indexes.append(schema.VectorIndex(index_name=self.index_vector,
index_type=index_type,
Expand Down Expand Up @@ -322,7 +340,8 @@ def _similarity_search_with_score(
meta = row_data.get(self.field_metadata)
if meta is not None:
meta = json.loads(meta)
doc = Document(page_content=row_data.get(self.field_text), metadata=meta) # type: ignore[arg-type]
doc = Document(page_content=row_data.get(self.field_text),
metadata=meta)
pair = (doc, result.get("distance", 0.0))
ret.append(pair)
return ret
Expand Down Expand Up @@ -379,7 +398,8 @@ def _max_marginal_relevance_search(
meta = row_data.get(self.field_metadata)
if meta is not None:
meta = json.loads(meta)
doc = Document(page_content=row_data.get(self.field_text), metadata=meta) # type: ignore[arg-type]
doc = Document(page_content=row_data.get(self.field_text),
metadata=meta)
documents.append(doc)
ordered_result_embeddings.append(row_data.get(self.field_vector))
# Get the new order of results.
Expand Down

0 comments on commit a003ed0

Please sign in to comment.