mirror of
https://github.com/Mintplex-Labs/langchain-python.git
synced 2026-07-19 21:33:31 -04:00
Serialize all the chains! (#761)
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e2a7fed890
commit
be7de427ca
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from pydantic import BaseModel, Extra
|
||||
from pydantic import BaseModel, Extra, Field
|
||||
|
||||
from langchain.chains.base import Chain
|
||||
from langchain.chains.llm import LLMChain
|
||||
@@ -26,7 +26,7 @@ class SQLDatabaseChain(Chain, BaseModel):
|
||||
|
||||
llm: BaseLLM
|
||||
"""LLM wrapper to use."""
|
||||
database: SQLDatabase
|
||||
database: SQLDatabase = Field(exclude=True)
|
||||
"""SQL Database to connect to."""
|
||||
prompt: BasePromptTemplate = PROMPT
|
||||
"""Prompt to use to translate natural language to SQL."""
|
||||
@@ -84,6 +84,10 @@ class SQLDatabaseChain(Chain, BaseModel):
|
||||
self.callback_manager.on_text(final_result, color="green", verbose=self.verbose)
|
||||
return {self.output_key: final_result}
|
||||
|
||||
@property
|
||||
def _chain_type(self) -> str:
|
||||
return "sql_database_chain"
|
||||
|
||||
|
||||
class SQLDatabaseSequentialChain(Chain, BaseModel):
|
||||
"""Chain for querying SQL database that is a sequential chain.
|
||||
@@ -153,3 +157,7 @@ class SQLDatabaseSequentialChain(Chain, BaseModel):
|
||||
"table_names_to_use": table_names_to_use,
|
||||
}
|
||||
return self.sql_chain(new_inputs, return_only_outputs=True)
|
||||
|
||||
@property
|
||||
def _chain_type(self) -> str:
|
||||
return "sql_database_sequential_chain"
|
||||
|
||||
Reference in New Issue
Block a user