Skip to content

Conversation

@pamelafox
Copy link
Contributor

Similar to Learn, but demonstrates use of a key.
Also made some consistency tweaks with related agents.

Copy link
Contributor

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 pull request adds two new example files demonstrating how to use the Tavily MCP server with API key authentication, and makes consistency improvements to related agent files.

Key Changes:

  • Adds LangChain and Agent Framework examples showing Tavily search integration with Bearer token authentication
  • Improves code consistency by standardizing logger names and moving logger.setLevel() calls to be immediately after logger creation
  • Simplifies code by removing unused imports and inlining constants

Reviewed changes

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

File Description
agents/langchainv1_tavily.py New LangChain example demonstrating Tavily MCP integration with API key authentication
agents/agentframework_tavily.py New Agent Framework example demonstrating Tavily MCP integration with API key authentication
agents/langchainv1_http.py Fixed logger name from "itinerario_lang" to "langchainv1_http" and moved setLevel() for consistency
agents/agentframework_learn.py Removed unused imports, fixed logger name, moved setLevel(), and inlined constant for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Load environment variables
load_dotenv(override=True)

api_host = os.getenv("API_HOST", "github")
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The variable name api_host should follow Python naming conventions for constants that are module-level configuration values. Since this value is determined at module load time and used to configure the model, it should be named API_HOST (all uppercase) to be consistent with other similar files in the codebase (e.g., langchainv1_http.py line 27, agentframework_tavily.py line 22).

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +52
model = ChatOpenAI(
model=os.environ.get("AZURE_OPENAI_CHAT_DEPLOYMENT"),
base_url=os.environ["AZURE_OPENAI_ENDPOINT"] + "/openai/v1/",
api_key=token_provider,
)
elif api_host == "github":
model = ChatOpenAI(
model=os.getenv("GITHUB_MODEL", "gpt-4o"),
base_url="https://models.inference.ai.azure.com",
api_key=SecretStr(os.environ["GITHUB_TOKEN"]),
)
elif api_host == "ollama":
model = ChatOpenAI(
model=os.environ.get("OLLAMA_MODEL", "llama3.1"),
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
api_key=SecretStr(os.environ.get("OLLAMA_API_KEY", "none")),
)
else:
model = ChatOpenAI(model=os.getenv("OPENAI_MODEL", "gpt-4o-mini"))
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The variable name model is inconsistent with similar files in the codebase. For example, langchainv1_http.py uses base_model for the same purpose. Using a more specific name like base_model or llm would improve code clarity and consistency across the codebase.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@madebygps madebygps left a comment

Choose a reason for hiding this comment

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

lgtm

@pamelafox pamelafox merged commit 51ecf1a into Azure-Samples:main Dec 18, 2025
8 checks passed
@pamelafox pamelafox deleted the tavily-example branch December 18, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants