I have a fairly complex project that I’m working that has a decent amount of data in the beginning and will grow pretty heavily over time. I assume putting data into a database for ease of access and management is the way to go. And if so, when will I be able to have GPT4 access this data through the API?
I’m already accessing my data (mysql) asking questions in natural language.
Works quite fine, even if, sometimes the prompt exceed the token limits (i’m using gpt-4 api).
Don’t really know if it fits your needs !?
import os
import tkinter as tk
import tkinter.ttk as ttk
from langchain.sql_database import SQLDatabase
from langchain.llms.openai import OpenAI
from langchain import SQLDatabaseChain
from langchain.prompts.prompt import PromptTemplate
from langchain.chains import SQLDatabaseSequentialChain
from langchain.chat_models import ChatOpenAI
from langchain.prompts.chat import (
ChatPromptTemplate,
SystemMessagePromptTemplate,
AIMessagePromptTemplate,
HumanMessagePromptTemplate,
)
from langchain.schema import (
AIMessage,
HumanMessage,
SystemMessage
)
#Define llm variables
os.environ[‘OPENAI_API_KEY’] = “Your API Key”
llm = ChatOpenAI(model_name=“gpt-4”, model=“gpt-4”, temperature=0)
#Connect to my local database
db = SQLDatabase.from_uri(“mysql://login:Password@127.0.0.1/DB_Name”)
_DEFAULT_TEMPLATE = “”" Let’s think step by step.
Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer.
Use the following format:
Question: “Question here”
SQLQuery: “SQL Query to run”
SQLResult: “Result of the SQLQuery”
Answer: “Final answer here”
def on_click():
# Get the query text from the entry widget
query = entry.get()
# Run the query using the agent executor
print(db_chain.sql_chain)
result = db_chain.run(query)
# Display the result in the text widget
text.delete("1.0", tk.END)
text.insert(tk.END, result)
@venk : No I don’t. I am working on a “Description table” of my database (which contains quite a lot of tables and a lot of datas)
Then I’ll try to pass it to the context in order to check if it resolves my problem