File size: 1,015 Bytes
c096dfe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from langchain import HuggingFaceHub
from langchain import  SQLDatabase
from langchain_experimental.sql.base import SQLDatabaseSequentialChain
from langchain_experimental.sql import SQLDatabaseChain
import json
import os
overal_temperature = 0.2
os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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"
llm = HuggingFaceHub(repo_id="juierror/flan-t5-text2sql-with-schema-v2",
                         model_kwargs={"temperature":overal_temperature,
                                       "max_new_tokens":200}
                         )
sqlite_db_path = "C:/Users/ankitkumar.singh/Desktop/streamlit/test_db.db"
db1 = SQLDatabase.from_uri(f"sqlite:///{sqlite_db_path}")
include_tables=['Employee','Album','Artist','Customer'],
db_chain = SQLDatabaseChain.from_llm(llm, db1, verbose=True, return_direct=True)
#user_input = input("Enter something: ")
#datbase=db_chain.run(user_input)
#print(datbase)
def process_input(input_text):
    
    Result=db_chain.run(input_text)
    return Result