Skip to content

Conversation

ks6088ts
Copy link
Member

What this PR does / why we need it

  • add sql database tool

Which issue(s) this PR fixes:

Fixes #48

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
ORGANIZATION=<organization-name>
REPOSITORY=<repository-name>

git clone [email protected]:$ORGANIZATION/$REPOSITORY.git
cd $REPOSITORY
  • Test the code
make ci-test

What to Check

Verify that the following are valid

  • ...

Additional Information

@ks6088ts ks6088ts self-assigned this Aug 10, 2025
@ks6088ts ks6088ts requested a review from Copilot August 10, 2025 00:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds SQL database tool functionality to the template_langgraph project, enabling the agent to interact with SQL databases. The changes introduce a configurable SQL database tool with SQLite as the default backend and integrate it into the existing tools framework.

  • Implements a new SQL database tool with configurable connection settings
  • Integrates the SQL tool into the default tools list for the chat agent
  • Enhances the chat interface to maintain conversation history across interactions

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
template_langgraph/tools/sql_database_tool.py Creates the SQL database tool with settings management and toolkit wrapper
template_langgraph/tools/common.py Adds SQL database tools to the default tools list
template_langgraph/services/streamlits/pages/chat_with_tools_agent.py Implements chat history persistence in the Streamlit interface
.env.template Adds SQL database URI configuration template

Comment on lines 8 to +15
DEFAULT_TOOLS = [
search_cosmosdb,
run_dify_workflow,
search_qdrant,
search_elasticsearch,
]
] + SqlDatabaseClientWrapper().get_tools(
llm=AzureOpenAiWrapper().chat_model,
)
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating SqlDatabaseClientWrapper and AzureOpenAiWrapper instances at module import time can cause initialization delays and potential connection issues. Consider lazy initialization or moving this to a function that's called when needed.

Copilot uses AI. Check for mistakes.

class SqlDatabaseClientWrapper:
def __init__(
self,
settings: Settings = None,
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using mutable default arguments with None and then reassigning is a common pattern, but using 'settings: Settings | None = None' would be more explicit about the type annotation in modern Python.

Suggested change
settings: Settings = None,
settings: Settings | None = None,

Copilot uses AI. Check for mistakes.

Comment on lines +12 to +15
if isinstance(msg, dict):
st.chat_message(msg["role"]).write(msg["content"])
else:
st.chat_message("assistant").write(msg.content)
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mixed message format handling (dict vs object with .content attribute) suggests inconsistent data structures. Consider standardizing the message format or adding type hints to clarify the expected structure.

Suggested change
if isinstance(msg, dict):
st.chat_message(msg["role"]).write(msg["content"])
else:
st.chat_message("assistant").write(msg.content)
st.chat_message(msg["role"]).write(msg["content"])

Copilot uses AI. Check for mistakes.

@ks6088ts ks6088ts merged commit 9c260c4 into main Aug 10, 2025
5 checks passed
@ks6088ts ks6088ts deleted the feature/issue-48_sql branch August 10, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add sql tool
1 participant