<< [[2025-01-18|Before]] | >>
## Goal
- `Streamlit Cloud`의 필요한 package 정리
- 프로젝트 배포
## TODO
> [!TODO] TODO
> - [v] Streamlit Cloud의 필요한 Packages 설치하기 / requirements.txt 수정
> - [v] OpenAI_API_KEY를 받고 Crew와 Langchain Class에 전달하기
> - [v] OpenAI_API_KEY 예외 처리하기
> - [v] Chat message Streaming 구현하기
## Issue/Solution
#### Issue 1
> [!blank]
>
>> [!warning]+ Problem
>>`Streamlit Cloud`에서 프로젝트를 배포하는 과정에서 `Could not build wheels for pysqlite3, which is required to install pyproject.toml-based project` 오류가 발생했다.
>>해당 오류는 **Streamlit Cloud**에서만 일어나는 오류로 어떠한 문제 때문에 일어나는지를 잘 모르겠다.
>
>> [!summary]+ Solution
>>해당 오류는 **pysqlite3**을 설치하고 불어오는 과정에서 일어나는 오류인 것 같다.
>>이 오류를 해결하기 위해서는 `import sys`을 통해 인터프리터의 모듈을 설정하여 직접 import을 시켜주면 해결 할 수 있다.
>>```python
>>__import__("pysqlite3")
> import sys
> sys.modules["sqlite3"] = sys.modules.pop("pysqlite3")
#### Issue 2
> [!blank]
>
>> [!warning]+ Problem
>>`CrewAI` 결과를 `Chat Message`로 보내주는데 해당 결과를 **Streaming**으로 보여주면 보기 좋을 것같다.
>>문제는 옵션에 따라 `main Crew`, `관련 문서 Refine Crew`, `관련 이미지 Refine Crew`을 사용할지 말지가 결정되기 때문에 상황에 맞게 `CrewAI`의 **CallBackHandler**를 사용하는게 힘들다는 것이다.
>
>> [!summary]+ Solution
>>`Streamlit`의 [[Streamlit#write_stream|write_stream]]을 이용하여 `Streaming`을 하는 것처럼 보이도록 구현하였다.
## Reference
- [Streamlit - pywin32](https://discuss.streamlit.io/t/pywin32/28679/2)
- [pysqlite3](https://stackoverflow.com/questions/78036617/error-could-not-find-a-version-that-satisfies-the-requirement-pysqlite3-binary)
- [[Streamlit#write_stream|Streamlit write stream]]
## Git commit contents
- [fix : pysqlite3 오류 수정](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/821babbf785a4800a1a29d852a2dd99a9e1d5588 "fix : pysqlite3 오류 수정")
- [docs : pip list pywin32 제거](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/586269b4209af34a52cae0c9d78ab46215353a19 "docs : pip list pywin32==308 제거")
- [build : streamlit openAI_API_KEY session 구현](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/2abd60ca73482e6feb338297bc0fa58ff9bf4c72 "build : streamlit openAI_API_KEY session 구현")
- [build : langChain과 CrewAI의 OpenAI API KEY 적용](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/0767b2b0ddafd2285cb885fc1887438541f60c19 "build : langChain과 CrewAI의 OpenAI API KEY 적용")
- [fix : utiles.py의 OpenAI API KEY 적용](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/fea159b1db0d968c33c294815cb8d1e82a675940 "fix : utiles.py의 OpenAI API KEY 적용")
- [fix : docPathSearcher, imgPathSearcher model을 gpt-4o-mini로 변경](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/594686cfaaf3fb0e770338eed247d1107e783865 "fix : docPathSearcher, imgPathSearcher model을 gpt-4o-mini로 변경")
- [fix : get_quiz_json 함수에 openAI API KEY parameter를 추가](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/34ab9c955d47c565e807891400bbfb02e60ecc81 "fix : get_quiz_json 함수에 openAI API KEY parameter를 추가")
- [build : OpenAI API KEY 오류 시 Error message UI 구현](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/cd85594cce6fadb7b37cb0dc80d6fafea72cf614 "build : OpenAI API KEY 오류 시 Error message UI 구현")
- [build : Chat message Streaming 구현](https://github.com/Donghyeon-Shin/DocumentSecretary/commit/1766dd168eccaba621b929da7785d91b99966ccb "build : Chat message Streaming 구현")