-
Notifications
You must be signed in to change notification settings - Fork 5
fix: 쿼리 생성시 AIMessage 에러 수정 및 리펙토링 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 동작확인했습니다. 너무 좋은 코드입니다. .content
는 제가 머지하다가 수정을 잘못한게 섞여들어온것 같습니다ㅜㅜ
💊 sql = res["generated_query"]
이 부분도 .content
를 추가해야 동작하는것으보 보이네요ㅎㅎ...
💬 이 이슈와는 별개로 지금 query_maker_chain
에서 리턴하는 형식을 바꿔야 쿼리를 clickhouse에서 실행하도록 할 수 있을것 같습니다. 테스트를 하는데 description도 같이 실행되면서 syntax 에러가 발생하네요
Traceback (most recent call last):
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.__dict__)
File "/home/pseudo.dwlee038/Lang2SQL/interface/streamlit_app.py", line 10, in <module>
pg.run()
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/streamlit/navigation/page.py", line 303, in run
exec(code, module.__dict__)
File "/home/pseudo.dwlee038/Lang2SQL/interface/lang2sql.py", line 135, in <module>
display_result(res=result, database=db)
File "/home/pseudo.dwlee038/Lang2SQL/interface/lang2sql.py", line 107, in display_result
df = database.run_sql(sql)
^^^^^^^^^^^^^^^^^^^^^
File "/home/pseudo.dwlee038/Lang2SQL/llm_utils/connect_db.py", line 44, in run_sql
raise e
File "/home/pseudo.dwlee038/Lang2SQL/llm_utils/connect_db.py", line 34, in run_sql
result = self.client.execute(sql, with_column_types=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/clickhouse_driver/client.py", line 382, in execute
rv = self.process_ordinary_query(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/clickhouse_driver/client.py", line 580, in process_ordinary_query
return self.receive_result(with_column_types=with_column_types,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/clickhouse_driver/client.py", line 212, in receive_result
return result.get_result()
^^^^^^^^^^^^^^^^^^^
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/clickhouse_driver/result.py", line 50, in get_result
for packet in self.packet_generator:
^^^^^^^^^^^^^^^^^^^^^
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/clickhouse_driver/client.py", line 228, in packet_generator
packet = self.receive_packet()
^^^^^^^^^^^^^^^^^^^^^
File "/home/pseudo.dwlee038/miniconda3/lib/python3.12/site-packages/clickhouse_driver/client.py", line 245, in receive_packet
raise packet.exception
clickhouse_driver.errors.ServerException: Code: 62.
DB::Exception: Unrecognized token: Syntax error: failed at position 748 (해) (line 24, col 2): 해석>
```plaintext
이 쿼리는 최근 3개월 동안 발생한 다양한 활동 유형에 대해 유니크한 유저 수를
카운트하기 위한 것입니다. 각 활동 유형은 NPS 설문, CES 설문... . Stack trace:
0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000f48e57b
1. DB::Exception::createDeprecated(String const&, int, bool) @ 0x000000000f5528cd
2. DB::parseQueryAndMovePosition(DB::IParser&, char const*&, char const*, String const&, bool, unsigned long, unsigned long, unsigned long) @ 0x0000000015730f72
3. DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*, std::shared_ptr<DB::IAST>&) @ 0x00000000138fc873
4. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x00000000138fbba4
5. DB::TCPHandler::runImpl() @ 0x0000000014c2aaec
6. DB::TCPHandler::run() @ 0x0000000014c48cd9
7. Poco::Net::TCPServerConnection::start() @ 0x00000000183727c7
8. Poco::Net::TCPServerDispatcher::run() @ 0x0000000018372c19
9. Poco::PooledThread::run() @ 0x000000001833ef5b
10. Poco::ThreadImpl::runnableEntry(void*) @ 0x000000001833d43d
11. ? @ 0x00007f1fb820eac3
12. ? @ 0x00007f1fb829fa04
@ehddnr301 |
|
||
graph = builder.compile() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💊: 논외기는 합니다만, 예전에 생각했던 건데 graph와 같은 부분을 session_state로 관리하는 것도 어떨까 생각이 듭니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nonegom 오 한번 확인해보겠습니다~~! 좋은 의견인 것 같아여!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍: 변경사항 확인했습니다~!
if st.session_state.get("show_total_token_usage", True): | ||
st.write("총 토큰 사용량:", total_tokens) | ||
if st.session_state.get("show_sql", True): | ||
st.write("결과:", "\n\n```sql\n" + res["generated_query"] + "\n```") | ||
st.write("결과:", "\n\n```sql\n" + res["generated_query"].content + "\n```") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💊: 해당 부분에서 오류가 발생하는 것 같은데, graph단에서 state를 업그레이드 할 때, String을 반환하는 것도 괜찮을 것 같다는 생각이 듭니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nonegom 다음 단계에서 바로 진행해보겠습니당!!
오잉 |
ㅇㅇ |
…dd-context fix: 쿼리 생성시 AIMessage 에러 수정 및 리펙토링
#️⃣ Issue Number
📝 요약(Summary)
💬 To Reviewers (선택)
PR Checklist
lang2sql --datahub_server http://34.125.222.80:8080 run-streamlit
reference) How to Code Review