mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-28 06:48:50 +00:00
community[patch]: Fix more issues (#26116)
This PR resolves more type checking issues and fixes some bugs.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Loads data from OneNote Notebooks"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Dict, Iterator, List, Optional
|
||||
from typing import Any, Dict, Iterator, List, Optional
|
||||
|
||||
import requests
|
||||
from langchain_core.documents import Document
|
||||
@@ -10,6 +10,7 @@ from pydantic import (
|
||||
Field,
|
||||
FilePath,
|
||||
SecretStr,
|
||||
model_validator,
|
||||
)
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
@@ -17,13 +18,14 @@ from langchain_community.document_loaders.base import BaseLoader
|
||||
|
||||
|
||||
class _OneNoteGraphSettings(BaseSettings):
|
||||
client_id: str = Field(..., alias="MS_GRAPH_CLIENT_ID")
|
||||
client_secret: SecretStr = Field(..., alias="MS_GRAPH_CLIENT_SECRET")
|
||||
client_id: str = Field(...)
|
||||
client_secret: SecretStr = Field(...)
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
case_sensitive=False,
|
||||
populate_by_name=True,
|
||||
env_file=".env",
|
||||
env_prefix="",
|
||||
env_prefix="MS_GRAPH_",
|
||||
)
|
||||
|
||||
|
||||
@@ -51,6 +53,14 @@ class OneNoteLoader(BaseLoader, BaseModel):
|
||||
object_ids: Optional[List[str]] = None
|
||||
""" The IDs of the objects to load data from."""
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def init(cls, values: Dict) -> Any:
|
||||
"""Initialize the class."""
|
||||
if "settings" in values and isinstance(values["settings"], dict):
|
||||
values["settings"] = _OneNoteGraphSettings(**values["settings"])
|
||||
return values
|
||||
|
||||
def lazy_load(self) -> Iterator[Document]:
|
||||
"""
|
||||
Get pages from OneNote notebooks.
|
||||
|
Reference in New Issue
Block a user