Skip to content

Commit

Permalink
solve some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
SonglinLyu committed Jan 16, 2025
1 parent e78c030 commit 3e934c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dbgpt/rag/transformer/intent_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import logging
import re
from typing import Dict, List
from typing import Dict, List, Union

from dbgpt.core import BaseMessage, HumanPromptTemplate, LLMClient
from dbgpt.rag.transformer.llm_translator import LLMTranslator
Expand Down Expand Up @@ -110,7 +110,7 @@ def _parse_response(self, text: str) -> Dict:
else:
text = ""

intention = dict()
intention: Dict[str, Union[str, List[str]]] = dict()
intention = json.loads(text)
if "category" not in intention:
intention["category"] = ""
Expand Down
2 changes: 1 addition & 1 deletion dbgpt/rag/transformer/text2gql.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _format_messages(self, text: str, history: str = None) -> List[BaseMessage]:

def _parse_response(self, text: str) -> Dict:
"""Parse llm response."""
translation = {}
translation: Dict[str, str] = {}
query = ""

code_block_pattern = re.compile(r"```cypher(.*?)```", re.S)
Expand Down
10 changes: 7 additions & 3 deletions dbgpt/storage/knowledge_graph/community_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import os
import uuid
from typing import List, Optional, Tuple, Union
from typing import Dict, List, Optional, Tuple, Union

from dbgpt._private.pydantic import ConfigDict, Field
from dbgpt.core import Chunk, LLMClient
Expand Down Expand Up @@ -542,12 +542,16 @@ async def asimilar_search_with_scores(

# if enable text2gql search, use translated query to retrieve subgraph
if self._graph_store.enable_text_search:
intention = await self._intent_interpreter.translate(text)
intention: Dict[
str, Union[str, List[str]]
] = await self._intent_interpreter.translate(text)
schema = json.dumps(
json.loads(self._graph_store_apdater.get_schema()), indent=4
)
intention["schema"] = schema
translation = await self._text2gql.translate(json.dumps(intention))
translation: Dict[str, str] = await self._text2gql.translate(
json.dumps(intention)
)
try:
query = translation["query"]
if "LIMIT" not in query:
Expand Down

0 comments on commit 3e934c2

Please sign in to comment.