Skip to content

Commit

Permalink
fix: fix and release petercat-utils (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingwanying authored Oct 15, 2024
1 parent 50f0255 commit caddc2c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
10 changes: 3 additions & 7 deletions petercat_utils/rag_helper/retrieval.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import json
from typing import Any, Dict


from langchain_community.vectorstores import SupabaseVectorStore
from langchain_openai import OpenAIEmbeddings

from core.dao.botDAO import BotDAO

from .github_file_loader import GithubFileLoader

from ..data_class import GitDocConfig, RAGGitDocConfig, S3Config
from ..db.client.supabase import get_client

Expand Down Expand Up @@ -173,13 +171,11 @@ def reload_knowledge(config: RAGGitDocConfig):

def search_knowledge(
query: str,
bot_id: str,
repo_name: str,
meta_filter: Dict[str, Any] = {},
):
bot_dao = BotDAO()
bot = bot_dao.get_bot(bot_id)
retriever = init_retriever(
{"filter": {"metadata": meta_filter, "repo_name": bot.repo_name}}
{"filter": {"metadata": meta_filter, "repo_name": repo_name}}
)
docs = retriever.invoke(query)
documents_as_dicts = [convert_document_to_dict(doc) for doc in docs]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "petercat_utils"
version = "0.1.35"
version = "0.1.37"
description = ""
authors = ["raoha.rh <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion server/agent/qa_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_tools(bot: Bot, auth_token: Optional[Auth.Token]):

return {
"check_login": login_tools["check_login"],
"search_knowledge": knowledge.factory(bot_id=bot.id),
"search_knowledge": knowledge.factory(repo_name=bot.repo_name),
"create_issue": issue_tools["create_issue"],
"get_issues": issue_tools["get_issues"],
"get_file_content": pull_request_tools["get_file_content"],
Expand Down
6 changes: 3 additions & 3 deletions server/agent/tools/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from petercat_utils import retrieval


def factory(bot_id: str):
bot_id = bot_id
def factory(repo_name: str):
repo_name = repo_name

@tool(parse_docstring=True)
def search_knowledge(
Expand All @@ -15,7 +15,7 @@ def search_knowledge(
query: The user's question.
"""
try:
return retrieval.search_knowledge(query, bot_id)
return retrieval.search_knowledge(query, repo_name)
except Exception as e:
print(f"An error occurred: {e}")
return None
Expand Down

0 comments on commit caddc2c

Please sign in to comment.