mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-05 04:55:14 +00:00
templates: Add neo4j semantic layer with ollama template (#17192)
A template with JSON-based agent using Mixtral via Ollama. --------- Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from typing import Optional, Type
|
||||
|
||||
from langchain.callbacks.manager import (
|
||||
AsyncCallbackManagerForToolRun,
|
||||
CallbackManagerForToolRun,
|
||||
)
|
||||
from langchain.pydantic_v1 import BaseModel, Field
|
||||
from langchain.tools import BaseTool
|
||||
|
||||
response = (
|
||||
"Create a final answer that says if they "
|
||||
"have any questions about movies or actors"
|
||||
)
|
||||
|
||||
|
||||
class SmalltalkInput(BaseModel):
|
||||
query: Optional[str] = Field(description="user query")
|
||||
|
||||
|
||||
class SmalltalkTool(BaseTool):
|
||||
name = "Smalltalk"
|
||||
description = "useful for when user greets you or wants to smalltalk"
|
||||
args_schema: Type[BaseModel] = SmalltalkInput
|
||||
|
||||
def _run(
|
||||
self,
|
||||
query: Optional[str] = None,
|
||||
run_manager: Optional[CallbackManagerForToolRun] = None,
|
||||
) -> str:
|
||||
"""Use the tool."""
|
||||
return response
|
||||
|
||||
async def _arun(
|
||||
self,
|
||||
query: Optional[str] = None,
|
||||
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
|
||||
) -> str:
|
||||
"""Use the tool asynchronously."""
|
||||
return response
|
Reference in New Issue
Block a user