instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Document all public functions with docstrings |
import logging
import os
import sys
import threading
from functools import lru_cache
from typing import Optional
_library_name = __name__.split(".", maxsplit=1)[0]
DEFAULT_HANDLER = None
_DEFAULT_LOGGING_LEVEL = logging.WARNING
_semaphore = threading.Lock()
def _get_library_root_logger() -> logging.Logger:
re... | --- +++ @@ -1,3 +1,11 @@+"""
+A centralized logging system for any library.
+This module provides functions to manage logging for a library. It includes
+functions to get and set the verbosity level, add and remove handlers, and
+control propagation. It also includes a function to set formatting for all
+handlers bound... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/utils/logging.py |
Add concise docstrings to each method |
from langchain_core.language_models.chat_models import BaseChatModel
from ..logging import get_logger
def num_tokens_mistral(text: str, llm_model: BaseChatModel) -> int:
logger = get_logger()
logger.debug(f"Counting tokens for text of {len(text)} characters")
try:
model = llm_model.model
e... | --- +++ @@ -1,3 +1,6 @@+"""
+Tokenization utilities for Mistral models
+"""
from langchain_core.language_models.chat_models import BaseChatModel
@@ -5,6 +8,17 @@
def num_tokens_mistral(text: str, llm_model: BaseChatModel) -> int:
+ """
+ Estimate the number of tokens in a given text using Mistral's token... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/utils/tokenizers/tokenizer_mistral.py |
Create docstrings for reusable components |
def transform_schema(pydantic_schema):
def process_properties(properties):
result = {}
for key, value in properties.items():
if "type" in value:
if value["type"] == "array":
if "items" in value and "$ref" in value["items"]:
r... | --- +++ @@ -1,6 +1,18 @@+"""
+This utility function transforms the pydantic schema into a more comprehensible schema.
+"""
def transform_schema(pydantic_schema):
+ """
+ Transform the pydantic schema into a more comprehensible JSON schema.
+
+ Args:
+ pydantic_schema (dict): The pydantic schema.
+
... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/utils/schema_trasform.py |
Document this script properly |
from langchain_core.language_models.chat_models import BaseChatModel
from ..logging import get_logger
def num_tokens_ollama(text: str, llm_model: BaseChatModel) -> int:
logger = get_logger()
logger.debug(f"Counting tokens for text of {len(text)} characters")
# Use langchain token count implementation... | --- +++ @@ -1,3 +1,6 @@+"""
+Tokenization utilities for Ollama models
+"""
from langchain_core.language_models.chat_models import BaseChatModel
@@ -5,6 +8,17 @@
def num_tokens_ollama(text: str, llm_model: BaseChatModel) -> int:
+ """
+ Estimate the number of tokens in a given text using Ollama's tokeniza... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/utils/tokenizers/tokenizer_ollama.py |
Document all endpoints with docstrings |
from .tokenizers.tokenizer_openai import num_tokens_openai
def num_tokens_calculus(string: str) -> int:
num_tokens_fn = num_tokens_openai
num_tokens = num_tokens_fn(string)
return num_tokens | --- +++ @@ -1,10 +1,16 @@+"""
+Module for counting tokens and splitting text into chunks
+"""
from .tokenizers.tokenizer_openai import num_tokens_openai
def num_tokens_calculus(string: str) -> int:
+ """
+ Returns the number of tokens in a text string.
+ """
num_tokens_fn = num_tokens_openai
... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/utils/tokenizer.py |
Add docstrings for better understanding |
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, List, Optional
from .models import CommandResult, FileSearchMatch
if TYPE_CHECKING:
from vanna.core.tool import ToolContext
class FileSystem(ABC):
@abstractmethod
async def list_files(self, directory: str, context: "ToolContext") ->... | --- +++ @@ -1,3 +1,8 @@+"""
+File system capability interface.
+
+This module contains the abstract base class for file system operations.
+"""
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, List, Optional
@@ -9,13 +14,16 @@
class FileSystem(ABC):
+ """Abstract base class for file syst... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/capabilities/file_system/base.py |
Fully document this Python code with docstrings |
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, List, Optional
if TYPE_CHECKING:
from vanna.core.tool import ToolContext
from .models import (
ToolMemorySearchResult,
TextMemory,
TextMemorySearchResult,
ToolMe... | --- +++ @@ -1,3 +1,9 @@+"""
+Agent memory capability interface for tool usage learning.
+
+This module contains the abstract base class for agent memory operations,
+following the same pattern as the FileSystem interface.
+"""
from __future__ import annotations
@@ -15,6 +21,7 @@
class AgentMemory(ABC):
+ ""... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/capabilities/agent_memory/base.py |
Help me add docstrings to my project | # -*- coding: utf-8 -*-
__author__ = 'JHao'
from helper.proxy import Proxy
from db.dbClient import DbClient
from handler.configHandler import ConfigHandler
class ProxyHandler(object):
def __init__(self):
self.conf = ConfigHandler()
self.db = DbClient(self.conf.dbConn)
self.db.changeTable... | --- +++ @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*-
+"""
+-------------------------------------------------
+ File Name: ProxyHandler.py
+ Description :
+ Author : JHao
+ date: 2016/12/3
+-------------------------------------------------
+ Change Activity:
+ 2016/12/03:
+ ... | https://raw.githubusercontent.com/jhao104/proxy_pool/HEAD/handler/proxyHandler.py |
Create docstrings for API functions |
import asyncio
import os
from pathlib import Path
from vanna import Agent
from vanna.core.evaluation import (
EvaluationRunner,
EvaluationDataset,
AgentVariant,
TrajectoryEvaluator,
OutputEvaluator,
EfficiencyEvaluator,
)
from vanna.integrations.anthropic import AnthropicLlmService
from vanna.... | --- +++ @@ -1,3 +1,10 @@+"""
+LLM Comparison Benchmark
+
+This script compares different LLMs on SQL generation tasks.
+Run from repository root:
+ PYTHONPATH=. python evals/benchmarks/llm_comparison.py
+"""
import asyncio
import os
@@ -18,11 +25,17 @@
def get_sql_tools() -> ToolRegistry:
+ """Get SQL-rel... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/evals/benchmarks/llm_comparison.py |
Write docstrings for this repository |
from dataclasses import dataclass
from typing import Optional
@dataclass
class FileSearchMatch:
path: str
snippet: Optional[str] = None
@dataclass
class CommandResult:
stdout: str
stderr: str
returncode: int | --- +++ @@ -1,3 +1,8 @@+"""
+File system capability models.
+
+This module contains data models for file system operations.
+"""
from dataclasses import dataclass
from typing import Optional
@@ -5,6 +10,7 @@
@dataclass
class FileSearchMatch:
+ """Represents a single search result within a file system."""
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/capabilities/file_system/models.py |
Write beginner-friendly docstrings |
from typing import Any, Dict, List, Optional
from pydantic import Field
from ....core.rich_component import RichComponent, ComponentType
class CardComponent(RichComponent):
type: ComponentType = ComponentType.CARD
title: str
content: str
subtitle: Optional[str] = None
icon: Optional[str] = None
... | --- +++ @@ -1,3 +1,4 @@+"""Card component for displaying structured information."""
from typing import Any, Dict, List, Optional
from pydantic import Field
@@ -5,6 +6,7 @@
class CardComponent(RichComponent):
+ """Card component for displaying structured information."""
type: ComponentType = ComponentT... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/containers/card.py |
Add detailed docstrings explaining each function |
from typing import Any, Dict, Optional, Union
from pydantic import Field
from ....core.rich_component import RichComponent, ComponentType
class ChartComponent(RichComponent):
type: ComponentType = ComponentType.CHART
chart_type: str # "line", "bar", "pie", "scatter", etc.
data: Dict[str, Any] # Chart ... | --- +++ @@ -1,3 +1,4 @@+"""Chart component for data visualization."""
from typing import Any, Dict, Optional, Union
from pydantic import Field
@@ -5,6 +6,7 @@
class ChartComponent(RichComponent):
+ """Chart component for data visualization."""
type: ComponentType = ComponentType.CHART
chart_type:... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/data/chart.py |
Create documentation strings for testing functions |
from typing import Any, Dict, List, Optional
from pydantic import BaseModel
class ToolMemory(BaseModel):
memory_id: Optional[str] = None
question: str
tool_name: str
args: Dict[str, Any]
timestamp: Optional[str] = None
success: bool = True
metadata: Optional[Dict[str, Any]] = None
cla... | --- +++ @@ -1,3 +1,6 @@+"""
+Memory storage models and types.
+"""
from typing import Any, Dict, List, Optional
@@ -5,6 +8,7 @@
class ToolMemory(BaseModel):
+ """Represents a stored tool usage memory."""
memory_id: Optional[str] = None
question: str
@@ -16,6 +20,7 @@
class TextMemory(BaseMod... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/capabilities/agent_memory/models.py |
Create docstrings for each class method |
from typing import Optional
from ....core.rich_component import RichComponent, ComponentType
class BadgeComponent(RichComponent):
type: ComponentType = ComponentType.BADGE
text: str
variant: str = (
"default" # "default", "primary", "success", "warning", "error", "info"
)
size: str = "m... | --- +++ @@ -1,9 +1,11 @@+"""Badge component for displaying status or labels."""
from typing import Optional
from ....core.rich_component import RichComponent, ComponentType
class BadgeComponent(RichComponent):
+ """Simple badge/pill component for displaying status or labels."""
type: ComponentType = ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/feedback/badge.py |
Document this module using docstrings |
from typing import Any, Dict, List, Optional
from pydantic import Field
from ....core.rich_component import RichComponent, ComponentType
class DataFrameComponent(RichComponent):
type: ComponentType = ComponentType.DATAFRAME
rows: List[Dict[str, Any]] = Field(default_factory=list) # List of row dictionaries... | --- +++ @@ -1,3 +1,4 @@+"""DataFrame component for displaying tabular data."""
from typing import Any, Dict, List, Optional
from pydantic import Field
@@ -5,6 +6,7 @@
class DataFrameComponent(RichComponent):
+ """DataFrame component specifically for displaying tabular data from SQL queries and similar source... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/data/dataframe.py |
Add documentation for all methods | #!/usr/bin/python
# -*- coding: UTF-8 -*-
from queue import Queue
import math
class TreeNode:
def __init__(self, val=None):
self.val = val
self.left = None
self.right = None
self.parent = None
class BinarySearchTree:
def __init__(self, val_list=[]):
self.root = None
... | --- +++ @@ -20,6 +20,11 @@ self.insert(n)
def insert(self, data):
+ """
+ 插入
+ :param data:
+ :return:
+ """
assert(isinstance(data, int))
if self.root is None:
@@ -44,6 +49,12 @@ return True
def search(self, data):
+ """
+ ... | https://raw.githubusercontent.com/wangzheng0822/algo/HEAD/python/23_binarytree/binary_search_tree.py |
Write docstrings for utility functions |
from typing import Any, Dict, List, Optional
from pydantic import Field
from ....core.rich_component import RichComponent, ComponentType
class StatusCardComponent(RichComponent):
type: ComponentType = ComponentType.STATUS_CARD
title: str
status: str # "pending", "running", "completed", "failed", "succe... | --- +++ @@ -1,3 +1,4 @@+"""Status card component for displaying process status."""
from typing import Any, Dict, List, Optional
from pydantic import Field
@@ -5,6 +6,7 @@
class StatusCardComponent(RichComponent):
+ """Generic status card that can display any process status."""
type: ComponentType = Co... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/feedback/status_card.py |
Add docstrings to my Python code |
from typing import Any, Dict, List, Optional
from pydantic import Field
from ....core.rich_component import RichComponent, ComponentType
class NotificationComponent(RichComponent):
type: ComponentType = ComponentType.NOTIFICATION
message: str
title: Optional[str] = None
level: str = "info" # "succe... | --- +++ @@ -1,3 +1,4 @@+"""Notification component for alerts and messages."""
from typing import Any, Dict, List, Optional
from pydantic import Field
@@ -5,6 +6,7 @@
class NotificationComponent(RichComponent):
+ """Notification component for alerts and messages."""
type: ComponentType = ComponentType.... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/feedback/notification.py |
Add standardized docstrings across the file |
from typing import Any, Dict, Optional
from ....core.rich_component import RichComponent, ComponentType
class ProgressBarComponent(RichComponent):
type: ComponentType = ComponentType.PROGRESS_BAR
value: float # 0.0 to 1.0
label: Optional[str] = None
show_percentage: bool = True
status: Optional... | --- +++ @@ -1,9 +1,11 @@+"""Progress components for displaying progress indicators."""
from typing import Any, Dict, Optional
from ....core.rich_component import RichComponent, ComponentType
class ProgressBarComponent(RichComponent):
+ """Progress bar with status and value."""
type: ComponentType = C... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/feedback/progress.py |
Add docstrings that explain logic |
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
from ....core.rich_component import RichComponent, ComponentType
class Task(BaseModel):
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
title: str
description: Optional... | --- +++ @@ -1,3 +1,4 @@+"""Task list component for interactive task tracking."""
import uuid
from datetime import datetime
@@ -7,6 +8,7 @@
class Task(BaseModel):
+ """Individual task in a task list."""
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
title: str
@@ -19,6 +21,7 @@
cla... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/interactive/task_list.py |
Add docstrings to incomplete code |
from typing import Any, Dict, List, Literal, Optional
from ....core.rich_component import ComponentType, RichComponent
class ButtonComponent(RichComponent):
def __init__(
self,
label: str,
action: str,
variant: Literal[
"primary", "secondary", "success", "warning", "e... | --- +++ @@ -1,9 +1,32 @@+"""Button component for interactive actions."""
from typing import Any, Dict, List, Literal, Optional
from ....core.rich_component import ComponentType, RichComponent
class ButtonComponent(RichComponent):
+ """Interactive button that sends a message when clicked.
+
+ The button r... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/interactive/button.py |
Provide docstrings following PEP 257 |
import uuid
from typing import Optional
from pydantic import Field
from ....core.rich_component import RichComponent, ComponentType
class ArtifactComponent(RichComponent):
type: ComponentType = ComponentType.ARTIFACT
artifact_id: str = Field(default_factory=lambda: f"artifact_{uuid.uuid4().hex[:8]}")
co... | --- +++ @@ -1,3 +1,4 @@+"""Artifact component for interactive content."""
import uuid
from typing import Optional
@@ -6,6 +7,7 @@
class ArtifactComponent(RichComponent):
+ """Component for displaying interactive artifacts that can be rendered externally."""
type: ComponentType = ComponentType.ARTIFACT... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/specialized/artifact.py |
Help me write clear docstrings |
from enum import Enum
from typing import Any, Optional
from .task_list import Task
from ....core.rich_component import RichComponent, ComponentType
class StatusBarUpdateComponent(RichComponent):
type: ComponentType = ComponentType.STATUS_BAR_UPDATE
status: str # "idle", "working", "success", "error"
me... | --- +++ @@ -1,3 +1,4 @@+"""UI state update components for controlling interface elements."""
from enum import Enum
from typing import Any, Optional
@@ -6,6 +7,7 @@
class StatusBarUpdateComponent(RichComponent):
+ """Component for updating the status bar above chat input."""
type: ComponentType = Compo... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/components/rich/interactive/ui_state.py |
Add return value explanations in docstrings |
import time
import warnings
from typing import Tuple
from ..telemetry import log_graph_execution
from ..utils import CustomLLMCallbackManager
from ..utils.logging import get_logger
logger = get_logger(__name__)
# ANSI escape sequence for hyperlink
CLICKABLE_URL = "\033]8;;https://scrapegraphai.com\033\\https://scra... | --- +++ @@ -1,3 +1,6 @@+"""
+base_graph module
+"""
import time
import warnings
@@ -13,6 +16,42 @@ CLICKABLE_URL = "\033]8;;https://scrapegraphai.com\033\\https://scrapegraphai.com\033]8;;\033\\"
class BaseGraph:
+ """
+ BaseGraph manages the execution flow of a graph composed of interconnected nodes.
+
+ ... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/graphs/base_graph.py |
Annotate my code with docstrings |
from typing import TYPE_CHECKING, Dict, List, Optional
from pydantic import BaseModel, Field
from .._compat import StrEnum
if TYPE_CHECKING:
from ..user import User
class UiFeature(StrEnum):
UI_FEATURE_SHOW_TOOL_NAMES = "tool_names"
UI_FEATURE_SHOW_TOOL_ARGUMENTS = "tool_arguments"
UI_FEATURE_SHOW... | --- +++ @@ -1,3 +1,8 @@+"""
+Agent configuration.
+
+This module contains configuration models that control agent behavior.
+"""
from typing import TYPE_CHECKING, Dict, List, Optional
@@ -28,6 +33,12 @@
class UiFeatures(BaseModel):
+ """UI features with group-based access control using the same pattern as t... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/agent/config.py |
Generate docstrings for each module |
import traceback
import uuid
from typing import TYPE_CHECKING, AsyncGenerator, List, Optional
from vanna.components import (
UiComponent,
SimpleTextComponent,
RichTextComponent,
StatusBarUpdateComponent,
TaskTrackerUpdateComponent,
ChatInputUpdateComponent,
StatusCardComponent,
Task,
)... | --- +++ @@ -1,3 +1,9 @@+"""
+Agent implementation for the Vanna Agents framework.
+
+This module provides the main Agent class that orchestrates the interaction
+between LLM services, tools, and conversation storage.
+"""
import traceback
import uuid
@@ -48,6 +54,30 @@
class Agent:
+ """Main agent implementa... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/agent/agent.py |
Document all endpoints with docstrings |
from abc import ABC
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from ..user.models import User
from ..llm.models import LlmMessage
class LlmContextEnhancer(ABC):
async def enhance_system_prompt(
self, system_prompt: str, user_message: str, user: "User"
) -> str:
ret... | --- +++ @@ -1,3 +1,9 @@+"""
+LLM context enhancer interface.
+
+LLM context enhancers allow you to add additional context to the system prompt
+and user messages before LLM calls.
+"""
from abc import ABC
from typing import TYPE_CHECKING, Optional
@@ -8,13 +14,81 @@
class LlmContextEnhancer(ABC):
+ """Enhanc... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/enhancer/base.py |
Create docstrings for reusable components |
from datetime import datetime
from typing import Any, Optional
from pydantic import BaseModel, Field, model_validator
class UiComponent(BaseModel):
timestamp: str = Field(default_factory=lambda: datetime.utcnow().isoformat())
rich_component: Any = Field(
..., description="Rich component for advance... | --- +++ @@ -1,3 +1,9 @@+"""
+UI component base class.
+
+This module defines the UiComponent class which is the return type for tool executions.
+It's placed in core/ because it's a fundamental type that tools return, not just a UI concern.
+"""
from datetime import datetime
from typing import Any, Optional
@@ -6,6... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/components.py |
Add standardized docstrings across the file |
import uuid
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Set, Union
from pydantic import BaseModel, Field
from ..components.rich import ComponentLifecycle, RichComponent
class UpdateOperation(str, Enum):
CREATE = "create"
UPDATE = "update"
REPLACE =... | --- +++ @@ -1,3 +1,6 @@+"""
+Component state management and update protocol for rich components.
+"""
import uuid
from datetime import datetime
@@ -10,6 +13,7 @@
class UpdateOperation(str, Enum):
+ """Types of component update operations."""
CREATE = "create"
UPDATE = "update"
@@ -20,6 +24,7 @@
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/component_manager.py |
Add docstrings to meet PEP guidelines |
try:
from enum import StrEnum # Py 3.11+
except ImportError: # Py < 3.11
from enum import Enum
class StrEnum(str, Enum): # type: ignore[no-redef]
pass
__all__ = ["StrEnum"] | --- +++ @@ -1,3 +1,9 @@+"""
+Compatibility shims for different Python versions.
+
+This module provides compatibility utilities for features that vary across
+Python versions.
+"""
try:
from enum import StrEnum # Py 3.11+
@@ -5,8 +11,9 @@ from enum import Enum
class StrEnum(str, Enum): # type: igno... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/_compat.py |
Document all endpoints with docstrings |
import hashlib
from abc import ABC, abstractmethod
from datetime import datetime
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from .models import (
AiResponseEvent,
AuditEvent,
ToolAccessCheckEvent,
ToolInvocationEvent,
ToolResultEvent,
UiFeatureAccessCheckEvent,
)
if TYPE_CHEC... | --- +++ @@ -1,3 +1,9 @@+"""
+Base audit logger interface.
+
+Audit loggers enable tracking user actions, tool invocations, and access control
+decisions for security, compliance, and debugging.
+"""
import hashlib
from abc import ABC, abstractmethod
@@ -19,9 +25,38 @@
class AuditLogger(ABC):
+ """Abstract ba... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/audit/base.py |
Generate NumPy-style docstrings |
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
from .._compat import StrEnum
class AuditEventType(StrEnum):
# Access control events
TOOL_ACCESS_CHECK = "tool_access_check"
UI_FEATURE_ACCESS_CHECK = "ui_feature_access_check"
... | --- +++ @@ -1,3 +1,8 @@+"""
+Audit event models.
+
+This module contains data models for audit logging events.
+"""
import uuid
from datetime import datetime
@@ -9,6 +14,7 @@
class AuditEventType(StrEnum):
+ """Types of audit events."""
# Access control events
TOOL_ACCESS_CHECK = "tool_access_che... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/audit/models.py |
Generate descriptive docstrings automatically |
from abc import ABC
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..tool.models import ToolContext
class ToolContextEnricher(ABC):
async def enrich_context(self, context: "ToolContext") -> "ToolContext":
return context | --- +++ @@ -1,3 +1,9 @@+"""
+Base context enricher interface.
+
+Context enrichers allow you to add additional data to the ToolContext
+before tools are executed.
+"""
from abc import ABC
from typing import TYPE_CHECKING
@@ -7,6 +13,47 @@
class ToolContextEnricher(ABC):
+ """Enricher for adding data to ToolC... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/enricher/base.py |
Generate documentation strings for clarity |
class AgentError(Exception):
pass
class ToolExecutionError(AgentError):
pass
class ToolNotFoundError(AgentError):
pass
class PermissionError(AgentError):
pass
class ConversationNotFoundError(AgentError):
pass
class LlmServiceError(AgentError):
pass
class ValidationError(Agent... | --- +++ @@ -1,35 +1,47 @@+"""
+Exception classes for the Vanna Agents framework.
+
+This module defines all custom exceptions used throughout the framework.
+"""
class AgentError(Exception):
+ """Base exception for agent framework."""
pass
class ToolExecutionError(AgentError):
+ """Error during t... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/errors.py |
Generate docstrings for this script |
from typing import TYPE_CHECKING, List, Optional
from .base import LlmContextEnhancer
if TYPE_CHECKING:
from ..user.models import User
from ..llm.models import LlmMessage
from ...capabilities.agent_memory import AgentMemory, TextMemorySearchResult
class DefaultLlmContextEnhancer(LlmContextEnhancer):
... | --- +++ @@ -1,3 +1,9 @@+"""
+Default LLM context enhancer implementation using AgentMemory.
+
+This implementation enriches the system prompt with relevant memories
+based on the user's initial message.
+"""
from typing import TYPE_CHECKING, List, Optional
from .base import LlmContextEnhancer
@@ -9,13 +15,45 @@
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/enhancer/default.py |
Create docstrings for all classes and functions |
import asyncio
from typing import Any, List, Dict, Optional, AsyncGenerator, TYPE_CHECKING
from datetime import datetime
from .base import (
TestCase,
AgentResult,
TestCaseResult,
AgentVariant,
Evaluator,
)
from vanna.core import UiComponent
from vanna.core.user.request_context import RequestConte... | --- +++ @@ -1,3 +1,10 @@+"""
+Evaluation runner with parallel execution support.
+
+This module provides the EvaluationRunner class that executes test cases
+against agents with configurable parallelism for efficient evaluation,
+especially when comparing multiple LLMs or model versions.
+"""
import asyncio
from ty... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/evaluation/runner.py |
Generate docstrings with parameter types |
import csv
from typing import List, Dict, Optional, Any
from dataclasses import dataclass, field
from datetime import datetime
from .base import TestCaseResult, AgentVariant, Evaluator, TestCase
@dataclass
class EvaluationReport:
agent_name: str
results: List[TestCaseResult]
evaluators: List[Evaluator]... | --- +++ @@ -1,3 +1,9 @@+"""
+Evaluation reporting with HTML, CSV, and console output.
+
+This module provides classes for generating evaluation reports,
+including comparison reports for evaluating multiple agent variants.
+"""
import csv
from typing import List, Dict, Optional, Any
@@ -9,6 +15,15 @@
@dataclass
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/evaluation/report.py |
Help me comply with documentation standards |
from typing import Dict, Any, Optional
from datetime import datetime
from .base import Evaluator, TestCase, AgentResult, EvaluationResult
from vanna.core import LlmService
class TrajectoryEvaluator(Evaluator):
@property
def name(self) -> str:
return "trajectory"
async def evaluate(
sel... | --- +++ @@ -1,3 +1,12 @@+"""
+Built-in evaluators for common evaluation tasks.
+
+This module provides ready-to-use evaluators for:
+- Trajectory evaluation (tools called, order, efficiency)
+- Output evaluation (content matching, quality)
+- LLM-as-judge evaluation (custom criteria)
+- Efficiency evaluation (time, tok... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/evaluation/evaluators.py |
Add documentation for all methods |
from abc import ABC
from typing import TYPE_CHECKING, Any, Optional
if TYPE_CHECKING:
from ..user.models import User
from ..tool import Tool
from ..tool.models import ToolContext, ToolResult
class LifecycleHook(ABC):
async def before_message(self, user: "User", message: str) -> Optional[str]:
... | --- +++ @@ -1,3 +1,9 @@+"""
+Base lifecycle hook interface.
+
+Lifecycle hooks allow you to intercept and customize agent behavior
+at key points in the execution flow.
+"""
from abc import ABC
from typing import TYPE_CHECKING, Any, Optional
@@ -9,15 +15,69 @@
class LifecycleHook(ABC):
+ """Hook into agent e... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/lifecycle/base.py |
Generate docstrings for each module |
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional, Callable
from dataclasses import dataclass, field
from datetime import datetime
from pydantic import BaseModel
from vanna.core import User, UiComponent
class ExpectedOutcome(BaseModel):
tools_called: Optional[List[str]] = None
... | --- +++ @@ -1,3 +1,9 @@+"""
+Core evaluation abstractions for the Vanna Agents framework.
+
+This module provides the base classes and models for evaluating agent behavior,
+including test cases, expected outcomes, and evaluation results.
+"""
from abc import ABC, abstractmethod
from typing import Any, Dict, List, ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/evaluation/base.py |
Document all public functions with docstrings |
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
from ..tool.models import ToolCall
from ..user.models import User
class LlmMessage(BaseModel):
role: str = Field(description="Message role")
content: str = Field(description="Message content")
tool_calls: Optional[List[... | --- +++ @@ -1,3 +1,8 @@+"""
+LLM domain models.
+
+This module contains data models for LLM communication.
+"""
from typing import Any, Dict, List, Optional
@@ -8,6 +13,7 @@
class LlmMessage(BaseModel):
+ """Message format for LLM communication."""
role: str = Field(description="Message role")
c... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/llm/models.py |
Write docstrings for algorithm functions |
from abc import ABC, abstractmethod
from typing import Any, AsyncGenerator, List
from .models import LlmRequest, LlmResponse, LlmStreamChunk
class LlmService(ABC):
@abstractmethod
async def send_request(self, request: LlmRequest) -> LlmResponse:
pass
@abstractmethod
async def stream_reques... | --- +++ @@ -1,3 +1,8 @@+"""
+LLM domain interface.
+
+This module contains the abstract base class for LLM services.
+"""
from abc import ABC, abstractmethod
from typing import Any, AsyncGenerator, List
@@ -6,19 +11,30 @@
class LlmService(ABC):
+ """Service for LLM communication."""
@abstractmethod
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/llm/base.py |
Add docstrings for production code |
import json
import yaml
from typing import Any, Dict, List
from pathlib import Path
from .base import TestCase, ExpectedOutcome
from vanna.core import User
class EvaluationDataset:
def __init__(self, name: str, test_cases: List[TestCase], description: str = ""):
self.name = name
self.test_cases... | --- +++ @@ -1,3 +1,9 @@+"""
+Dataset loaders for evaluation test cases.
+
+This module provides utilities for loading test case datasets from
+YAML and JSON files.
+"""
import json
import yaml
@@ -9,14 +15,43 @@
class EvaluationDataset:
+ """Collection of test cases with metadata.
+
+ Example YAML format:... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/evaluation/dataset.py |
Write clean docstrings for readability |
from abc import ABC
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..llm import LlmRequest, LlmResponse
class LlmMiddleware(ABC):
async def before_llm_request(self, request: "LlmRequest") -> "LlmRequest":
return request
async def after_llm_response(
self, request: "LlmRequest"... | --- +++ @@ -1,3 +1,9 @@+"""
+Base LLM middleware interface.
+
+Middleware allows you to intercept and transform LLM requests and responses
+for caching, monitoring, content filtering, and more.
+"""
from abc import ABC
from typing import TYPE_CHECKING
@@ -7,11 +13,57 @@
class LlmMiddleware(ABC):
+ """Middlew... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/middleware/base.py |
Add structured docstrings to improve clarity |
from abc import ABC
from typing import TYPE_CHECKING
from .models import RecoveryAction, RecoveryActionType
if TYPE_CHECKING:
from ..tool.models import ToolContext
from ..llm import LlmRequest
class ErrorRecoveryStrategy(ABC):
async def handle_tool_error(
self, error: Exception, context: "Tool... | --- +++ @@ -1,3 +1,9 @@+"""
+Base error recovery strategy interface.
+
+Recovery strategies allow you to customize how the agent handles errors
+during tool execution and LLM communication.
+"""
from abc import ABC
from typing import TYPE_CHECKING
@@ -10,10 +16,50 @@
class ErrorRecoveryStrategy(ABC):
+ """St... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/recovery/base.py |
Add docstrings to incomplete code |
from abc import ABC
from typing import TYPE_CHECKING, List
if TYPE_CHECKING:
from ..storage import Message
class ConversationFilter(ABC):
async def filter_messages(self, messages: List["Message"]) -> List["Message"]:
return messages | --- +++ @@ -1,3 +1,9 @@+"""
+Base conversation filter interface.
+
+Conversation filters allow you to transform conversation history before
+it's sent to the LLM for processing.
+"""
from abc import ABC
from typing import TYPE_CHECKING, List
@@ -7,6 +13,55 @@
class ConversationFilter(ABC):
+ """Filter for tr... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/filter/base.py |
Create docstrings for reusable components |
from abc import ABC
from typing import Any, Dict, Optional
from .models import Span, Metric
class ObservabilityProvider(ABC):
async def record_metric(
self,
name: str,
value: float,
unit: str = "",
tags: Optional[Dict[str, str]] = None,
) -> None:
pass
a... | --- +++ @@ -1,3 +1,9 @@+"""
+Base observability provider interface.
+
+Observability providers allow you to collect telemetry data about
+agent execution for monitoring and debugging.
+"""
from abc import ABC
from typing import Any, Dict, Optional
@@ -6,6 +12,38 @@
class ObservabilityProvider(ABC):
+ """Prov... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/observability/base.py |
Create docstrings for all classes and functions |
import time
from typing import Any, Dict, Optional
from uuid import uuid4
from pydantic import BaseModel, Field
class Span(BaseModel):
id: str = Field(default_factory=lambda: str(uuid4()), description="Span ID")
name: str = Field(description="Span name/operation")
start_time: float = Field(default_fact... | --- +++ @@ -1,3 +1,6 @@+"""
+Observability models for spans and metrics.
+"""
import time
from typing import Any, Dict, Optional
@@ -7,6 +10,7 @@
class Span(BaseModel):
+ """Represents a unit of work for distributed tracing."""
id: str = Field(default_factory=lambda: str(uuid4()), description="Span ID... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/observability/models.py |
Generate NumPy-style docstrings |
from enum import Enum
from typing import Any, Optional
from pydantic import BaseModel, Field
class RecoveryActionType(str, Enum):
RETRY = "retry"
FAIL = "fail"
FALLBACK = "fallback"
SKIP = "skip"
class RecoveryAction(BaseModel):
action: RecoveryActionType = Field(description="Type of recover... | --- +++ @@ -1,3 +1,6 @@+"""
+Recovery action models for error handling.
+"""
from enum import Enum
from typing import Any, Optional
@@ -6,6 +9,7 @@
class RecoveryActionType(str, Enum):
+ """Types of recovery actions."""
RETRY = "retry"
FAIL = "fail"
@@ -14,6 +18,7 @@
class RecoveryAction(Base... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/recovery/models.py |
Write docstrings describing functionality |
import time
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, TypeVar, Union
from .tool import Tool, ToolCall, ToolContext, ToolRejection, ToolResult, ToolSchema
from .user import User
if TYPE_CHECKING:
from .audit import AuditLogger
from .agent.config import AuditConfig
T = TypeVar("T")
... | --- +++ @@ -1,3 +1,8 @@+"""
+Tool registry for the Vanna Agents framework.
+
+This module provides the ToolRegistry class for managing and executing tools.
+"""
import time
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, TypeVar, Union
@@ -13,6 +18,7 @@
class _LocalToolWrapper(Tool[T]):
+ ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/registry.py |
Create docstrings for API functions |
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, List, Optional
if TYPE_CHECKING:
from ..tool.models import ToolSchema
from ..user.models import User
class SystemPromptBuilder(ABC):
@abstractmethod
async def build_system_prompt(
self, user: "User", tools: List["ToolSche... | --- +++ @@ -1,3 +1,8 @@+"""
+System prompt builder interface.
+
+This module contains the abstract base class for system prompt builders.
+"""
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, List, Optional
@@ -8,9 +13,24 @@
class SystemPromptBuilder(ABC):
+ """Abstract base class for sy... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/system_prompt/base.py |
Document all public functions with docstrings |
import uuid
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, TypeVar
from pydantic import BaseModel, Field
# Type variable for self-returning methods
T = TypeVar("T", bound="RichComponent")
class ComponentType(str, Enum):
# Basic components
TEXT = "text"
CARD = "... | --- +++ @@ -1,3 +1,9 @@+"""
+Base classes for rich UI components.
+
+This module provides the base RichComponent class and supporting enums
+for the component system.
+"""
import uuid
from datetime import datetime
@@ -11,6 +17,7 @@
class ComponentType(str, Enum):
+ """Types of rich UI components."""
#... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/rich_component.py |
Document all endpoints with docstrings |
from typing import TYPE_CHECKING, List, Optional
from datetime import datetime
from .base import SystemPromptBuilder
if TYPE_CHECKING:
from ..tool.models import ToolSchema
from ..user.models import User
class DefaultSystemPromptBuilder(SystemPromptBuilder):
def __init__(self, base_prompt: Optional[str... | --- +++ @@ -1,3 +1,9 @@+"""
+Default system prompt builder implementation with memory workflow support.
+
+This module provides a default implementation of the SystemPromptBuilder interface
+that automatically includes memory workflow instructions when memory tools are available.
+"""
from typing import TYPE_CHECKIN... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/system_prompt/default.py |
Help me add docstrings to my project |
from abc import ABC, abstractmethod
from typing import List, Optional
from .models import Conversation
from ..user.models import User
class ConversationStore(ABC):
@abstractmethod
async def create_conversation(
self, conversation_id: str, user: User, initial_message: str
) -> Conversation:
... | --- +++ @@ -1,3 +1,8 @@+"""
+Storage domain interface.
+
+This module contains the abstract base class for conversation storage.
+"""
from abc import ABC, abstractmethod
from typing import List, Optional
@@ -7,29 +12,35 @@
class ConversationStore(ABC):
+ """Abstract base class for conversation storage."""
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/storage/base.py |
Generate consistent docstrings |
from abc import ABC, abstractmethod
from typing import Generic, List, Type, TypeVar
from .models import ToolContext, ToolResult, ToolSchema
# Type variable for tool argument types
T = TypeVar("T")
class Tool(ABC, Generic[T]):
@property
@abstractmethod
def name(self) -> str:
pass
@property... | --- +++ @@ -1,3 +1,8 @@+"""
+Tool domain interface.
+
+This module contains the abstract base class for tools.
+"""
from abc import ABC, abstractmethod
from typing import Generic, List, Type, TypeVar
@@ -9,30 +14,45 @@
class Tool(ABC, Generic[T]):
+ """Abstract base class for tools."""
@property
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/tool/base.py |
Add docstrings with type hints explained |
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
class RequestContext(BaseModel):
cookies: Dict[str, str] = Field(default_factory=dict, description="Request cookies")
headers: Dict[str, str] = Field(default_factory=dict, description="Request headers")
remote_addr: Optional... | --- +++ @@ -1,3 +1,9 @@+"""
+Request context for user resolution.
+
+This module provides the RequestContext model for passing web request
+information to UserResolver implementations.
+"""
from typing import Any, Dict, Optional
@@ -5,6 +11,20 @@
class RequestContext(BaseModel):
+ """Context from a web requ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/user/request_context.py |
Fully document this Python code with docstrings |
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
from enum import Enum
class SimpleComponentType(str, Enum):
TEXT = "text"
IMAGE = "image"
LINK = "link"
class SimpleComponent(BaseModel):
type: SimpleComponentType = Field(..., description="Type of the component.")
se... | --- +++ @@ -1,3 +1,4 @@+"""Base classes for simple UI components."""
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
@@ -11,6 +12,7 @@
class SimpleComponent(BaseModel):
+ """A simple UI component with basic attributes."""
type: SimpleComponentType = Field(..., description=... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/simple_component.py |
Add docstrings for utility scripts |
from typing import TYPE_CHECKING, List, Optional, Dict, Any
import traceback
import uuid
from .base import WorkflowHandler, WorkflowResult
if TYPE_CHECKING:
from ..agent.agent import Agent
from ..user.models import User
from ..storage import Conversation
# Import components at module level to avoid circu... | --- +++ @@ -1,3 +1,9 @@+"""
+Default workflow handler implementation with setup health checking.
+
+This module provides a default implementation of the WorkflowHandler interface
+that provides a smart starter UI based on available tools and setup status.
+"""
from typing import TYPE_CHECKING, List, Optional, Dict, ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/workflow/default.py |
Write docstrings including parameters and return values |
from abc import ABC, abstractmethod
from .models import User
from .request_context import RequestContext
class UserResolver(ABC):
@abstractmethod
async def resolve_user(self, request_context: RequestContext) -> User:
pass | --- +++ @@ -1,3 +1,9 @@+"""
+User resolver interface for web request authentication.
+
+This module provides the abstract base class for resolving web requests
+to authenticated User objects.
+"""
from abc import ABC, abstractmethod
@@ -6,7 +12,31 @@
class UserResolver(ABC):
+ """Resolves web requests to au... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/user/resolver.py |
Write proper docstrings for these functions |
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, ConfigDict, Field
class User(BaseModel):
id: str = Field(description="Unique user identifier")
username: Optional[str] = Field(default=None, description="Username")
email: Optional[str] = Field(default=None, description="User ... | --- +++ @@ -1,3 +1,8 @@+"""
+User domain models.
+
+This module contains data models for user management.
+"""
from typing import Any, Dict, List, Optional
@@ -5,6 +10,7 @@
class User(BaseModel):
+ """User model for authentication and scoping."""
id: str = Field(description="Unique user identifier")
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/user/models.py |
Add docstrings to improve collaboration |
from datetime import datetime
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
from ..tool.models import ToolCall
from ..user.models import User
class Message(BaseModel):
role: str = Field(description="Message role (user/assistant/system/tool)")
content: str = Field(descr... | --- +++ @@ -1,3 +1,8 @@+"""
+Storage domain models.
+
+This module contains data models for conversation storage.
+"""
from datetime import datetime
from typing import Any, Dict, List, Optional
@@ -9,6 +14,7 @@
class Message(BaseModel):
+ """Single message in a conversation."""
role: str = Field(descr... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/storage/models.py |
Add docstrings to existing functions |
from abc import ABC, abstractmethod
from typing import (
TYPE_CHECKING,
Optional,
Union,
List,
AsyncGenerator,
Callable,
Awaitable,
)
from dataclasses import dataclass
if TYPE_CHECKING:
from ..user.models import User
from ..storage import Conversation
from ...components import ... | --- +++ @@ -1,3 +1,13 @@+"""
+Base workflow handler interface.
+
+Workflow triggers allow you to execute deterministic workflows in response to
+user messages before they are sent to the LLM. This is useful for:
+- Command handling (e.g., /help, /reset)
+- Pattern-based routing (e.g., report generation)
+- State-based ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/workflow/base.py |
Write documentation strings for class attributes |
from .agent_memory import ChromaAgentMemory
def get_device() -> str:
try:
import torch
# Check for CUDA (NVIDIA GPUs)
if torch.cuda.is_available():
return "cuda"
# Check for MPS (Apple Silicon GPUs)
if hasattr(torch.backends, "mps") and torch.backends.mps.is_... | --- +++ @@ -1,8 +1,33 @@+"""
+ChromaDB integration for Vanna Agents.
+"""
from .agent_memory import ChromaAgentMemory
def get_device() -> str:
+ """Detect the best available device for embeddings.
+
+ This function checks for GPU availability and returns the appropriate device string
+ for use with emb... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/chromadb/__init__.py |
Generate docstrings with examples |
from __future__ import annotations
import json
import os
from typing import Any, AsyncGenerator, Dict, List, Optional, Set
from vanna.core.llm import (
LlmService,
LlmRequest,
LlmResponse,
LlmStreamChunk,
)
from vanna.core.tool import ToolCall, ToolSchema
# Models that don't support temperature and... | --- +++ @@ -1,3 +1,10 @@+"""
+Azure OpenAI LLM service implementation.
+
+Provides an `LlmService` backed by Azure OpenAI Chat Completions (openai>=1.0.0)
+with support for streaming, deployment-scoped models, and Azure-specific
+authentication flows.
+"""
from __future__ import annotations
@@ -29,11 +36,28 @@
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/azureopenai/llm.py |
Provide docstrings following PEP 257 |
from __future__ import annotations
import logging
import os
from typing import Any, AsyncGenerator, Dict, List, Optional, Tuple
logger = logging.getLogger(__name__)
from vanna.core.llm import (
LlmService,
LlmRequest,
LlmResponse,
LlmStreamChunk,
)
from vanna.core.tool import ToolCall, ToolSchema
... | --- +++ @@ -1,3 +1,11 @@+"""
+Anthropic LLM service implementation.
+
+Implements the LlmService interface using Anthropic's Messages API
+(anthropic>=0.8.0). Supports non-streaming and streaming text output.
+Tool-calls (tool_use blocks) are surfaced at the end of a stream or after a
+non-streaming call as ToolCall en... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/anthropic/llm.py |
Add return value explanations in docstrings |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class ClickHouseRunner(SqlRunner):
def __init__(
self,
host: str,
database: str,
user: str,
password: str,
... | --- +++ @@ -1,3 +1,4 @@+"""ClickHouse implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,6 +8,7 @@
class ClickHouseRunner(SqlRunner):
+ """ClickHouse implementation of the SqlRunner interface."""
def __init__(
self,
@@ -17,6 +19,16 @@ port:... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/clickhouse/sql_runner.py |
Write docstrings including parameters and return values |
import json
import hashlib
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
try:
import chromadb
from chromadb.config import Settings
from chromadb.utils import embedding_functions
try:
from chromadb.er... | --- +++ @@ -1,3 +1,8 @@+"""
+Local vector database implementation of AgentMemory.
+
+This implementation uses ChromaDB for local vector storage of tool usage patterns.
+"""
import json
import hashlib
@@ -16,6 +21,7 @@ except ImportError:
# Fallback for older ChromaDB versions that don't have chromadb.e... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/chromadb/agent_memory.py |
Create Google-style docstrings for my code |
import json
import uuid
import pickle
import os
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
import numpy as np
try:
import faiss
FAISS_AVAILABLE = True
except ImportError:
FAISS_AVAILABLE = False
from vanna.c... | --- +++ @@ -1,3 +1,8 @@+"""
+FAISS vector database implementation of AgentMemory.
+
+This implementation uses FAISS for local vector storage of tool usage patterns.
+"""
import json
import uuid
@@ -27,6 +32,7 @@
class FAISSAgentMemory(AgentMemory):
+ """FAISS-based implementation of AgentMemory."""
de... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/faiss/agent_memory.py |
Replace inline comments with docstrings |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class BigQueryRunner(SqlRunner):
def __init__(self, project_id: str, cred_file_path: Optional[str] = None, **kwargs):
try:
from google.... | --- +++ @@ -1,3 +1,4 @@+"""BigQuery implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,8 +8,16 @@
class BigQueryRunner(SqlRunner):
+ """BigQuery implementation of the SqlRunner interface."""
def __init__(self, project_id: str, cred_file_path: Optional[str] ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/bigquery/sql_runner.py |
Auto-generate documentation strings for this file |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class DuckDBRunner(SqlRunner):
def __init__(
self, database_path: str = ":memory:", init_sql: Optional[str] = None, **kwargs
):
try:
... | --- +++ @@ -1,3 +1,4 @@+"""DuckDB implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,10 +8,20 @@
class DuckDBRunner(SqlRunner):
+ """DuckDB implementation of the SqlRunner interface."""
def __init__(
self, database_path: str = ":memory:", init_sql:... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/duckdb/sql_runner.py |
Annotate my code with docstrings |
from abc import ABC, abstractmethod
from typing import Any, Dict, Optional
from .models import User
class UserService(ABC):
@abstractmethod
async def get_user(self, user_id: str) -> Optional[User]:
pass
@abstractmethod
async def authenticate(self, credentials: Dict[str, Any]) -> Optional[U... | --- +++ @@ -1,3 +1,8 @@+"""
+User domain interface.
+
+This module contains the abstract base class for user services.
+"""
from abc import ABC, abstractmethod
from typing import Any, Dict, Optional
@@ -6,15 +11,19 @@
class UserService(ABC):
+ """Service for user management and authentication."""
@abs... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/user/base.py |
Create structured documentation for my script |
from typing import Any, Dict, List, Tuple, Type
from pydantic import BaseModel
import importlib
import inspect
def validate_pydantic_models_in_package(package_name: str) -> Dict[str, Any]:
results: Dict[str, Any] = {
"total_models": 0,
"incomplete_models": [],
"models": {},
"summa... | --- +++ @@ -1,3 +1,9 @@+"""
+Development utilities for validating Pydantic models.
+
+This module provides utilities that can be used during development
+and testing to catch forward reference issues early.
+"""
from typing import Any, Dict, List, Tuple, Type
from pydantic import BaseModel
@@ -6,6 +12,18 @@
def... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/core/validation.py |
Document this script properly |
import json
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
try:
from azure.search.documents import SearchClient
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.... | --- +++ @@ -1,3 +1,8 @@+"""
+Azure AI Search implementation of AgentMemory.
+
+This implementation uses Azure Cognitive Search for vector storage of tool usage patterns.
+"""
import json
import uuid
@@ -33,6 +38,7 @@
class AzureAISearchAgentMemory(AgentMemory):
+ """Azure AI Search-based implementation of Ag... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/azuresearch/agent_memory.py |
Help me write clear docstrings |
import json
import logging
from typing import Optional
from vanna.core.audit import AuditEvent, AuditLogger
logger = logging.getLogger(__name__)
class LoggingAuditLogger(AuditLogger):
def __init__(self, log_level: int = logging.INFO):
self.log_level = log_level
async def log_event(self, event: Au... | --- +++ @@ -1,3 +1,9 @@+"""
+Local audit logger implementation using Python logging.
+
+This module provides a simple audit logger that writes events using
+the standard Python logging module, useful for development and testing.
+"""
import json
import logging
@@ -9,11 +15,33 @@
class LoggingAuditLogger(AuditLo... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/local/audit.py |
Can you add docstrings to this Python file? |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class HiveRunner(SqlRunner):
def __init__(
self,
host: str,
database: str = "default",
user: Optional[str] = None,
... | --- +++ @@ -1,3 +1,4 @@+"""Hive implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,6 +8,7 @@
class HiveRunner(SqlRunner):
+ """Hive implementation of the SqlRunner interface."""
def __init__(
self,
@@ -18,6 +20,17 @@ auth: str = "CUSTOM",
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/hive/sql_runner.py |
Generate helpful docstrings for debugging |
import json
import os
from pathlib import Path
from typing import Dict, List, Optional
from datetime import datetime
import time
from vanna.core.storage import ConversationStore, Conversation, Message
from vanna.core.user import User
class FileSystemConversationStore(ConversationStore):
def __init__(self, base... | --- +++ @@ -1,3 +1,9 @@+"""
+File system conversation store implementation.
+
+This module provides a file-based implementation of the ConversationStore
+interface that persists conversations to disk as a directory structure.
+"""
import json
import os
@@ -11,21 +17,38 @@
class FileSystemConversationStore(Conve... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/local/file_system_conversation_store.py |
Generate docstrings for each module |
from typing import Dict, List, Optional
from vanna.core.storage import ConversationStore, Conversation, Message
from vanna.core.user import User
class MemoryConversationStore(ConversationStore):
def __init__(self) -> None:
self._conversations: Dict[str, Conversation] = {}
async def create_conversa... | --- +++ @@ -1,3 +1,9 @@+"""
+In-memory conversation store implementation.
+
+This module provides a simple in-memory implementation of the ConversationStore
+interface, useful for testing and development.
+"""
from typing import Dict, List, Optional
@@ -6,6 +12,7 @@
class MemoryConversationStore(ConversationSt... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/local/storage.py |
Add docstrings following best practices |
from __future__ import annotations
import json
import logging
import os
from typing import Any, AsyncGenerator, Dict, List, Optional
logger = logging.getLogger(__name__)
from vanna.core.llm import (
LlmService,
LlmRequest,
LlmResponse,
LlmStreamChunk,
)
from vanna.core.tool import ToolCall, ToolSche... | --- +++ @@ -1,3 +1,10 @@+"""
+Google Gemini LLM service implementation.
+
+Implements the LlmService interface using Google's Gen AI SDK
+(google-genai). Supports non-streaming and streaming text output,
+as well as function calling (tool use).
+"""
from __future__ import annotations
@@ -18,6 +25,16 @@
class G... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/google/gemini.py |
Write docstrings for data processing functions |
import json
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
try:
import marqo
MARQO_AVAILABLE = True
except ImportError:
MARQO_AVAILABLE = False
from vanna.capabilities.agent_memory import (
Agent... | --- +++ @@ -1,3 +1,8 @@+"""
+Marqo vector database implementation of AgentMemory.
+
+This implementation uses Marqo for vector storage of tool usage patterns.
+"""
import json
import uuid
@@ -24,6 +29,7 @@
class MarqoAgentMemory(AgentMemory):
+ """Marqo-based implementation of AgentMemory."""
def __in... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/marqo/agent_memory.py |
Write docstrings describing each step |
import asyncio
from typing import AsyncGenerator, List
from vanna.core.llm import LlmService, LlmRequest, LlmResponse, LlmStreamChunk
from vanna.core.tool import ToolSchema
class MockLlmService(LlmService):
def __init__(self, response_content: str = "Hello! This is a mock response."):
self.response_con... | --- +++ @@ -1,3 +1,9 @@+"""
+Mock LLM service implementation for testing.
+
+This module provides a simple mock implementation of the LlmService interface,
+useful for testing and development without requiring actual LLM API calls.
+"""
import asyncio
from typing import AsyncGenerator, List
@@ -7,12 +13,14 @@
c... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/mock/llm.py |
Document all endpoints with docstrings |
from __future__ import annotations
import asyncio
import difflib
import time
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
from vanna.capabilities.agent_memory import (
AgentMemory,
TextMemory,
TextMemorySearchResult,
ToolMemory,
ToolMemorySearchResult,
)
... | --- +++ @@ -1,3 +1,10 @@+"""
+Demo in-memory implementation of AgentMemory.
+
+This implementation provides a zero-dependency, minimal storage solution that
+keeps all memories in RAM. It uses simple similarity algorithms (Jaccard and
+difflib) instead of vector embeddings. Perfect for demos and testing.
+"""
from _... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/local/agent_memory/in_memory.py |
Create docstrings for API functions |
import asyncio
import hashlib
from pathlib import Path
from typing import List, Optional
from vanna.capabilities.file_system import CommandResult, FileSearchMatch, FileSystem
from vanna.core.tool import ToolContext
MAX_SEARCH_FILE_BYTES = 1_000_000
class LocalFileSystem(FileSystem):
def __init__(self, working... | --- +++ @@ -1,3 +1,8 @@+"""
+Local file system implementation.
+
+This module provides a local file system implementation with per-user isolation.
+"""
import asyncio
import hashlib
@@ -11,11 +16,25 @@
class LocalFileSystem(FileSystem):
+ """Local file system implementation with per-user isolation."""
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/local/file_system.py |
Add docstrings to improve readability |
import json
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
try:
from pymilvus import (
connections,
Collection,
CollectionSchema,
FieldSchema,
DataType,
utility,... | --- +++ @@ -1,3 +1,8 @@+"""
+Milvus vector database implementation of AgentMemory.
+
+This implementation uses Milvus for distributed vector storage of tool usage patterns.
+"""
import json
import uuid
@@ -31,6 +36,7 @@
class MilvusAgentMemory(AgentMemory):
+ """Milvus-based implementation of AgentMemory."""... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/milvus/agent_memory.py |
Add docstrings following best practices |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class MySQLRunner(SqlRunner):
def __init__(
self,
host: str,
database: str,
user: str,
password: str,
port:... | --- +++ @@ -1,3 +1,4 @@+"""MySQL implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,6 +8,7 @@
class MySQLRunner(SqlRunner):
+ """MySQL implementation of the SqlRunner interface."""
def __init__(
self,
@@ -17,6 +19,16 @@ port: int = 3306,
... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/mysql/sql_runner.py |
Add concise docstrings to each method |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class MSSQLRunner(SqlRunner):
def __init__(self, odbc_conn_str: str, **kwargs):
try:
import pyodbc
self.pyodbc = pyodbc
... | --- +++ @@ -1,3 +1,4 @@+"""Microsoft SQL Server implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,8 +8,15 @@
class MSSQLRunner(SqlRunner):
+ """Microsoft SQL Server implementation of the SqlRunner interface."""
def __init__(self, odbc_conn_str: str, **kwar... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/mssql/sql_runner.py |
Add verbose docstrings with examples |
from __future__ import annotations
import json
import os
from typing import Any, AsyncGenerator, Dict, List, Optional
from vanna.core.llm import (
LlmService,
LlmRequest,
LlmResponse,
LlmStreamChunk,
)
from vanna.core.tool import ToolCall, ToolSchema
class OllamaLlmService(LlmService):
def __i... | --- +++ @@ -1,3 +1,10 @@+"""
+Ollama LLM service implementation.
+
+This module provides an implementation of the LlmService interface backed by
+Ollama's local LLM API. It supports non-streaming responses and streaming
+of text content. Tool calling support depends on the Ollama model being used.
+"""
from __future... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/ollama/llm.py |
Generate docstrings with parameter types |
from __future__ import annotations
import json
import os
from typing import Any, AsyncGenerator, Dict, List, Optional, cast
from vanna.core.llm import (
LlmService,
LlmRequest,
LlmResponse,
LlmStreamChunk,
)
from vanna.core.tool import ToolCall, ToolSchema
class OpenAILlmService(LlmService):
d... | --- +++ @@ -1,3 +1,13 @@+"""
+OpenAI LLM service implementation.
+
+This module provides an implementation of the LlmService interface backed by
+OpenAI's Chat Completions API (openai>=1.0.0). It supports non-streaming
+responses and best-effort streaming of text content. Tool/function calling is
+passed through when t... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/openai/llm.py |
Can you add docstrings to this Python file? |
import json
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
try:
from opensearchpy import OpenSearch, helpers
OPENSEARCH_AVAILABLE = True
except ImportError:
OPENSEARCH_AVAILABLE = False
from vanna.ca... | --- +++ @@ -1,3 +1,8 @@+"""
+OpenSearch vector database implementation of AgentMemory.
+
+This implementation uses OpenSearch for distributed search and storage of tool usage patterns.
+"""
import json
import uuid
@@ -24,6 +29,7 @@
class OpenSearchAgentMemory(AgentMemory):
+ """OpenSearch-based implementatio... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/opensearch/agent_memory.py |
Generate docstrings with parameter types |
from copy import deepcopy
from typing import List, Optional, Type
from pydantic import BaseModel
from ..nodes import GraphIteratorNode, MergeAnswersNode
from ..utils.copy import safe_deepcopy
from .abstract_graph import AbstractGraph
from .base_graph import BaseGraph
from .csv_scraper_graph import CSVScraperGraph
... | --- +++ @@ -1,3 +1,6 @@+"""
+CSVScraperMultiGraph Module
+"""
from copy import deepcopy
from typing import List, Optional, Type
@@ -12,6 +15,32 @@
class CSVScraperMultiGraph(AbstractGraph):
+ """
+ CSVScraperMultiGraph is a scraping pipeline that
+ scrapes a list of URLs and generates answers to a give... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/graphs/csv_scraper_multi_graph.py |
Add detailed documentation for each class |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class PrestoRunner(SqlRunner):
def __init__(
self,
host: str,
catalog: str = "hive",
schema: str = "default",
user:... | --- +++ @@ -1,3 +1,4 @@+"""Presto implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,6 +8,7 @@
class PrestoRunner(SqlRunner):
+ """Presto implementation of the SqlRunner interface."""
def __init__(
self,
@@ -21,6 +23,20 @@ requests_kwargs: ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/presto/sql_runner.py |
Generate docstrings with examples |
import json
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
try:
from pinecone import Pinecone, ServerlessSpec
PINECONE_AVAILABLE = True
except ImportError:
PINECONE_AVAILABLE = False
from vanna.capab... | --- +++ @@ -1,3 +1,8 @@+"""
+Pinecone vector database implementation of AgentMemory.
+
+This implementation uses Pinecone for cloud-based vector storage of tool usage patterns.
+"""
import json
import uuid
@@ -24,6 +29,7 @@
class PineconeAgentMemory(AgentMemory):
+ """Pinecone-based implementation of AgentMe... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/pinecone/agent_memory.py |
Write docstrings for backend logic |
from copy import deepcopy
from typing import List, Optional, Type
from pydantic import BaseModel
from ..nodes import GraphIteratorNode, MergeAnswersNode, SearchInternetNode
from ..utils.copy import safe_deepcopy
from .abstract_graph import AbstractGraph
from .base_graph import BaseGraph
from .smart_scraper_graph imp... | --- +++ @@ -1,3 +1,6 @@+"""
+SearchGraph Module
+"""
from copy import deepcopy
from typing import List, Optional, Type
@@ -12,6 +15,32 @@
class SearchGraph(AbstractGraph):
+ """
+ SearchGraph is a scraping pipeline that searches the internet for answers to a given prompt.
+ It only requires a user prom... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/graphs/search_graph.py |
Add docstrings to improve readability |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class OracleRunner(SqlRunner):
def __init__(self, user: str, password: str, dsn: str, **kwargs):
try:
import oracledb
self... | --- +++ @@ -1,3 +1,4 @@+"""Oracle implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,8 +8,17 @@
class OracleRunner(SqlRunner):
+ """Oracle implementation of the SqlRunner interface."""
def __init__(self, user: str, password: str, dsn: str, **kwargs):
+ ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/oracle/sql_runner.py |
Add docstrings to incomplete code |
from typing import Optional, Type
from pydantic import BaseModel
from ..nodes import FetchScreenNode, GenerateAnswerFromImageNode
from .abstract_graph import AbstractGraph
from .base_graph import BaseGraph
class ScreenshotScraperGraph(AbstractGraph):
def __init__(
self,
prompt: str,
so... | --- +++ @@ -1,3 +1,6 @@+"""
+ScreenshotScraperGraph Module
+"""
from typing import Optional, Type
@@ -9,6 +12,25 @@
class ScreenshotScraperGraph(AbstractGraph):
+ """
+ A graph instance representing the web scraping workflow for images.
+
+ Attributes:
+ prompt (str): The input text to be scrap... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/graphs/screenshot_scraper_graph.py |
Write Python docstrings for this snippet |
from typing import Optional
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class PostgresRunner(SqlRunner):
def __init__(
self,
connection_string: Optional[str] = None,
host: Optional[str] = None,
p... | --- +++ @@ -1,3 +1,4 @@+"""PostgreSQL implementation of SqlRunner interface."""
from typing import Optional
import pandas as pd
@@ -7,6 +8,7 @@
class PostgresRunner(SqlRunner):
+ """PostgreSQL implementation of the SqlRunner interface."""
def __init__(
self,
@@ -18,6 +20,20 @@ passwor... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/postgres/sql_runner.py |
Generate documentation strings for clarity |
from copy import deepcopy
from typing import List, Optional, Type
from pydantic import BaseModel
from ..nodes import GraphIteratorNode, MergeGeneratedScriptsNode
from ..utils.copy import safe_deepcopy
from .abstract_graph import AbstractGraph
from .base_graph import BaseGraph
from .script_creator_graph import Script... | --- +++ @@ -1,3 +1,6 @@+"""
+ScriptCreatorMultiGraph Module
+"""
from copy import deepcopy
from typing import List, Optional, Type
@@ -12,6 +15,31 @@
class ScriptCreatorMultiGraph(AbstractGraph):
+ """
+ ScriptCreatorMultiGraph is a scraping pipeline that scrapes a list
+ of URLs generating web scrapin... | https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/HEAD/scrapegraphai/graphs/script_creator_multi_graph.py |
Create docstrings for each class method |
import json
import uuid
from datetime import datetime
from typing import Any, Dict, List, Optional
import asyncio
from concurrent.futures import ThreadPoolExecutor
try:
from qdrant_client import QdrantClient
from qdrant_client.models import (
Distance,
VectorParams,
PointStruct,
... | --- +++ @@ -1,3 +1,8 @@+"""
+Qdrant vector database implementation of AgentMemory.
+
+This implementation uses Qdrant for vector storage of tool usage patterns.
+"""
import json
import uuid
@@ -32,6 +37,7 @@
class QdrantAgentMemory(AgentMemory):
+ """Qdrant-based implementation of AgentMemory."""
def ... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/qdrant/agent_memory.py |
Can you add docstrings to this Python file? |
from typing import Optional, Union
import os
import pandas as pd
from vanna.capabilities.sql_runner import SqlRunner, RunSqlToolArgs
from vanna.core.tool import ToolContext
class SnowflakeRunner(SqlRunner):
def __init__(
self,
account: str,
username: str,
password: Optional[str]... | --- +++ @@ -1,3 +1,4 @@+"""Snowflake implementation of SqlRunner interface."""
from typing import Optional, Union
import os
@@ -8,6 +9,7 @@
class SnowflakeRunner(SqlRunner):
+ """Snowflake implementation of the SqlRunner interface."""
def __init__(
self,
@@ -22,6 +24,25 @@ private_key... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/integrations/snowflake/sql_runner.py |
Add docstrings to make code maintainable | import dataclasses
import json
import os
from dataclasses import dataclass
from typing import Callable, List, Tuple, Union
import pandas as pd
import requests
import plotly.graph_objs
from .exceptions import (
OTPCodeError,
ValidationError,
)
from .types import (
ApiKey,
Status,
TrainingData,
... | --- +++ @@ -74,6 +74,21 @@
def get_api_key(email: str, otp_code: Union[str, None] = None) -> str:
+ """
+ **Example:**
+ ```python
+ vn.get_api_key(email="my-email@example.com")
+ ```
+
+ Login to the Vanna.AI API.
+
+ Args:
+ email (str): The email address to login with.
+ otp_co... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/legacy/__init__.py |
Expand my code with proper documentation strings | from typing import List
from zhipuai import ZhipuAI
from chromadb import Documents, EmbeddingFunction, Embeddings
from ..base import VannaBase
class ZhipuAI_Embeddings(VannaBase):
def __init__(self, config=None):
VannaBase.__init__(self, config=config)
if "api_key" not in config:
rais... | --- +++ @@ -5,6 +5,12 @@
class ZhipuAI_Embeddings(VannaBase):
+ """
+ [future functionality] This function is used to generate embeddings from ZhipuAI.
+
+ Args:
+ VannaBase (_type_): _description_
+ """
def __init__(self, config=None):
VannaBase.__init__(self, config=config)
@@ -... | https://raw.githubusercontent.com/vanna-ai/vanna/HEAD/src/vanna/legacy/ZhipuAI/ZhipuAI_embeddings.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.