Find answers from the community

Home
Members
Chanh Le
C
Chanh Le
Offline, last seen 3 months ago
Joined September 25, 2024
C
Chanh Le
·

code

code
Plain Text
os.environ["OPENAI_API_KEY"] = "sk-"
import nest_asyncio
nest_asyncio.apply()
from llama_index import SimpleDirectoryReader
documents = SimpleDirectoryReader(input_dir='rag_data_dir').load_data()
from services.dense_pack.base import DenseXRetrievalPack
from llama_index.llms import OpenAI
from llama_index.text_splitter import SentenceSplitter
dense_pack = DenseXRetrievalPack(
    documents,
    proposition_llm=OpenAI(model="gpt-3.5-turbo", max_tokens=750),
    query_llm=OpenAI(model="gpt-3.5-turbo", max_tokens=256),
    text_splitter=SentenceSplitter(chunk_size=1024),
)
dense_query_engine = dense_pack.query_engine


I got AttributeError: 'OpenAI' object has no attribute 'apredict' when running on python 3.10.x
But when successfully on python 3.11.x
2 comments
L
W
I am having this issue don't know what is it issue

Plain Text
2023-08-15 22:10:48 sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT player_name, player_position\nFROM players\nJOIN clubs ON players.player_cl' at line 6")
2023-08-15 22:10:48 [SQL: SELECT COUNT(*) AS num_players
2023-08-15 22:10:48 FROM players
2023-08-15 22:10:48 JOIN clubs ON players.player_club_id = clubs.club_id
2023-08-15 22:10:48 WHERE clubs.club_name = 'Arsenal FC';
2023-08-15 22:10:48 
2023-08-15 22:10:48 SELECT player_name, player_position
2023-08-15 22:10:48 FROM players
2023-08-15 22:10:48 JOIN clubs ON players.player_club_id = clubs.club_id
2023-08-15 22:10:48 WHERE clubs.club_name = 'Arsenal FC'
2023-08-15 22:10:48 LIMIT 5;]
2023-08-15 22:10:48 (Background on this error at: https://sqlalche.me/e/20/f405)
2023-08-15 22:10:48 192.168.112.5 - - [15/Aug/2023 15:10:48] "POST /chat HTTP/1.0" 500 -

with code to create index
Plain Text
        sql_engine = get_sql_engine(env)
        sql_database = SQLDatabase(sql_engine)
        builder = SQLContextContainerBuilder(sql_database)
        context_builder = builder.build_context_container()
        service_context = ServiceContext.from_defaults(llm=api.llm)
        index = GPTSQLStructStoreIndex([],
                                       sql_database=sql_database,
                                       sql_context_container=context_builder,
                                       service_context=service_context)

I ran the query both work fine.
Have you faced it before?
2 comments
C
because I can't run query after it. it all return. Doesn't generate the query anymore.
Plain Text
 sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Given an input question, first create a syntactically correct mysql query to run' at line 1")
[SQL: Given an input question, first create a syntactically correct mysql query to run, then look at the results of the query and return the answer. You can order the results by a relevant column to return the most interesting examples in the database.
Never query for all the columns from a specific table, only ask for a few relevant columns given the question.
Pay attention to use only the column names that you can see in the schema description. Be careful to not query for columns that do not exist. Pay attention to which column is in which table. Also, qualify column names with the table name when needed.
Use the following format:
Question: Question here
SQLQuery: SQL Query to run]
(Background on this error at: https://sqlalche.me/e/20/f405)
>>> response = query_engine.query("Which club play in England Premier League?"
8 comments
L
C
I have the same issue.
Do you know how to solve it?
2 comments
C
L
I am using llama index to build a local chat of data from mysql.
i don't want to use openAI api and wanna build a local chat - small model around <=1GB can you help suggest 1 model please.
Thanks
2 comments
C
L