-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/cosmosdb crud #146
Conversation
とりあえずですが作成しました。イメージと違うとこあったら教えてください。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以前の自分のコードの部分かもですが、気になった部分をレビューしました
あとazure.coreのloggerがうるさかったのでワーニング以上のlogしか出力されないように変更するコードを別途プッシュするのでプルお願いします
logger.info("documentを更新します") | ||
|
||
# metadataのupdated_atを更新 | ||
query = "SELECT c.metadata FROM c WHERE c.id = " + f"'{id}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここでf-stringで埋め込んでいるが、_similarity_search_with_scoreメソッドのようにparametersを使用して埋め込んであげたほうがよさそう
query = "SELECT c.metadata FROM c WHERE c.id = @id"
parameters = [{"name": "@id", "value": id}]
item = self._container.query_items(
query=query, parameters=parameters, enable_cross_partition_query=True
).next()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query_itemメソッドがparameters
にlist[dict[str, object]]
をふっているせいかmypyエラー出ます。
cast関数でlist[dict[str, Any]]
にするとエラー吐かないのでキャストしてます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query_itemメソッドが
parameters
にlist[dict[str, object]]
をふっているせいかmypyエラー出ます。 cast関数でlist[dict[str, Any]]
にするとエラー吐かないのでキャストしてます。
良いと思います
|
||
def _max_level(text: str) -> int: | ||
"""Markdownのヘッダーの最大レベルを返す関数""" | ||
level = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re module使ったらもう少し簡単に書ける
headers = re.findall(r"^#+", text, re.MULTILINE)
return max([len(h) for h in headers]) if headers else 0
ツールの動作確認しました。現在、ベクターサーチの結果からidを取得してidでもう一度クエリした結果を返すようになっているのですが、ベクターサーチの結果をそのまま返すようにしても問題無いでしょうか? |
langchain側でデフォルトでidを取得するようになっていたのでオーバーライドを削除しました。 |
概要
CosmosDBManagerにCRUDを実装する
変更点
このセクションでは、具体的な変更点や修正箇所を箇条書きでリストアップしてください。
ドキュメントの削除は継承元のdelete_document_by_idで行えることを確認しました。
関連Issue
このセクションでは、このPRが関連するIssueをリンクしてください。以下のように記述します。