mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
chore(ollama): switch to ty (#36571)
This commit is contained in:
@@ -15,13 +15,14 @@ service.
|
||||
|
||||
from importlib import metadata
|
||||
from importlib.metadata import PackageNotFoundError
|
||||
from typing import NoReturn
|
||||
|
||||
from langchain_ollama.chat_models import ChatOllama
|
||||
from langchain_ollama.embeddings import OllamaEmbeddings
|
||||
from langchain_ollama.llms import OllamaLLM
|
||||
|
||||
|
||||
def _raise_package_not_found_error() -> None:
|
||||
def _raise_package_not_found_error() -> NoReturn:
|
||||
raise PackageNotFoundError
|
||||
|
||||
|
||||
|
||||
@@ -1539,7 +1539,7 @@ class ChatOllama(BaseChatModel):
|
||||
)
|
||||
if is_pydantic_schema:
|
||||
output_parser: Runnable = PydanticToolsParser(
|
||||
tools=[schema], # type: ignore[list-item]
|
||||
tools=[schema], # ty: ignore[invalid-argument-type]
|
||||
first_tool_only=True,
|
||||
)
|
||||
else:
|
||||
@@ -1555,7 +1555,7 @@ class ChatOllama(BaseChatModel):
|
||||
},
|
||||
)
|
||||
output_parser = (
|
||||
PydanticOutputParser(pydantic_object=schema) # type: ignore[arg-type]
|
||||
PydanticOutputParser(pydantic_object=schema) # ty: ignore[invalid-argument-type]
|
||||
if is_pydantic_schema
|
||||
else JsonOutputParser()
|
||||
)
|
||||
@@ -1579,7 +1579,7 @@ class ChatOllama(BaseChatModel):
|
||||
"schema": schema,
|
||||
},
|
||||
)
|
||||
output_parser = PydanticOutputParser(pydantic_object=schema) # type: ignore[arg-type]
|
||||
output_parser = PydanticOutputParser(pydantic_object=schema)
|
||||
else:
|
||||
if is_typeddict(schema):
|
||||
response_format = convert_to_json_schema(schema)
|
||||
|
||||
@@ -475,7 +475,7 @@ class OllamaLLM(BaseLLM):
|
||||
**kwargs,
|
||||
)
|
||||
generations.append([final_chunk])
|
||||
return LLMResult(generations=generations) # type: ignore[arg-type]
|
||||
return LLMResult(generations=generations)
|
||||
|
||||
async def _agenerate(
|
||||
self,
|
||||
@@ -494,7 +494,7 @@ class OllamaLLM(BaseLLM):
|
||||
**kwargs,
|
||||
)
|
||||
generations.append([final_chunk])
|
||||
return LLMResult(generations=generations) # type: ignore[arg-type]
|
||||
return LLMResult(generations=generations)
|
||||
|
||||
def _stream(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user