[AI] LLM RAG 환경 구성 - 3 LangServe 구성 > 머신러닝/AI 자료실

본문 바로가기
사이트 내 전체검색

머신러닝/AI 자료실

[AI] LLM RAG 환경 구성 - 3 LangServe 구성

페이지 정보

profile_image
작성자 꿈꾸는여행자
댓글 0건 조회 210회 작성일 24-09-13 10:41

본문

안녕하세요.

 

꿈꾸는여행자입니다.

 

 

LLM RAG 환경 구성을 다루고자 합니다.


이번 항목에서는 

 

LangServe 구성 실습을 진행해 보도록 하겠습니다. 

 

상세 내역은 아래와 같습니다.



감사합니다. 


> 아래 

 

3. LangServe 

3.1. Prepare 

3.1.1. git clone

* github에서 Source를 Download 받음 

   * git clone https://github.com/teddylee777/langserve_ollama



mv langserve_ollama/* langserve_ollama/.* ./



rmdir langserve_ollama/

(env) [lds@llm llm]$ git clone https://github.com/teddylee777/langserve_ollama

Cloning into 'langserve_ollama'...

remote: Enumerating objects: 105, done.

remote: Counting objects: 100% (105/105), done.

remote: Compressing objects: 100% (71/71), done.

remote: Total 105 (delta 54), reused 76 (delta 27), pack-reused 0

Receiving objects: 100% (105/105), 374.26 KiB | 4.11 MiB/s, done.

Resolving deltas: 100% (54/54), done.

(env) [lds@llm llm]$ 

(env) [lds@llm llm]$ mv langserve_ollama/* langserve_ollama/.* ./

mv: cannot move 'langserve_ollama/.' to './.': Device or resource busy

mv: cannot move 'langserve_ollama/..' to './..': Device or resource busy

(env) [lds@llm llm]$ rmdir langserve_ollama/

(env) [lds@llm llm]$ ls -al

total 7474620

drwxr-xr-x. 8 lds lds       4096 May  2 17:35 .

drwxr-xr-x. 3 lds lds         17 May  2 17:31 ..

drwxr-xr-x. 2 lds lds        125 May  2 17:33 app

drwxr-xr-x. 5 lds lds         74 May  2 16:17 env

drwxr-xr-x. 3 lds lds       4096 May  2 17:33 example

-rw-r--r--. 1 lds lds 7653486272 May  2 16:42 ggml-model-Q5_K_M.gguf

drwxr-xr-x. 8 lds lds        163 May  2 17:33 .git

-rw-r--r--. 1 lds lds         50 May  2 17:33 .gitignore

drwxr-xr-x. 2 lds lds         41 May  2 17:33 images

-rw-r--r--. 1 lds lds        318 May  2 16:46 Modelfile

drwxr-xr-x. 6 lds lds        141 May  2 17:33 ollama-modelfile

-rw-r--r--. 1 lds lds     481043 May  2 17:33 poetry.lock

-rw-r--r--. 1 lds lds        659 May  2 17:33 pyproject.toml

-rw-r--r--. 1 lds lds       3343 May  2 17:33 README.md

-rw-r--r--. 1 lds lds      14983 May  2 17:33 requirements.txt

(env) [lds@llm llm]$ 



   * 


3.1.2. Install Python Packages

* Install

   * https://python.langchain.com/docs/get_started/installation/

      * requirements.txt 파일 Package 설치시 너무 오래 걸림 1시간 넘게

pip install -r requirements.txt



pip install "langserve[all]"



pip install langchain_community



pip install langchain_openai

(env) [lds@llm llm]$ pip install "langserve[all]"

Collecting langserve[all]

  Downloading langserve-0.1.1-py3-none-any.whl (1.2 MB)

     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 3.8 MB/s eta 0:00:00

Collecting fastapi<1,>=0.90.1

  Downloading fastapi-0.111.0-py3-none-any.whl (91 kB)

     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 92.0/92.0 kB 160.6 kB/s eta 0:00:00

Collecting httpx>=0.23.0

  Using cached httpx-0.27.0-py3-none-any.whl (75 kB)

      Successfully uninstalled packaging-24.0

Successfully installed MarkupSafe-2.1.5 annotated-types-0.6.0 anyio-4.3.0 click-8.1.7 dnspython-2.6.1 email_validator-2.1.1 fastapi-0.111.0 fastapi-cli-0.0.2 h11-0.14.0 httpcore-1.0.5 httptools-0.6.1 httpx-0.27.0 jinja2-3.1.3 jsonpatch-1.33 jsonpointer-2.4 langchain-core-0.1.50 langserve-0.1.1 langsmith-0.1.53 markdown-it-py-3.0.0 mdurl-0.1.2 orjson-3.10.2 packaging-23.2 pydantic-2.7.1 pydantic-core-2.18.2 pygments-2.17.2 python-dotenv-1.0.1 python-multipart-0.0.9 rich-13.7.1 shellingham-1.5.4 sniffio-1.3.1 sse-starlette-1.8.2 starlette-0.37.2 tenacity-8.2.3 typer-0.12.3 ujson-5.9.0 uvicorn-0.29.0 uvloop-0.19.0 watchfiles-0.21.0 websockets-12.0



[notice] A new release of pip available: 22.3.1 -> 24.0

[notice] To update, run: pip install --upgrade pip

(env) [lds@llm llm]$ 




3.1.3. Check Source

* pycharm community 사용 

   * sh pycharm.sh 

[lds@host bin]$ pwd

/home/lds/Work/pycharm-community-2023.3.5/bin

[lds@host bin]$ sh pycharm.sh 

CompileCommand: exclude com/intellij/openapi/vfs/impl/FilePartNodeRoot.trieDescend bool exclude = true

2024-05-03 09:22:47,109 [    312]   WARN - #c.i.s.ComponentManagerImpl - `preload=true` must be used only for core services (service=com.intellij.ae.database.core.baseEvents.fus.AddStatisticsEventLogListenerTemporary, plugin=com.jetbrains.ae.database)

2024-05-03 09:22:47,110 [    313]   WARN - #c.i.s.ComponentManagerImpl - `preload=true` must be used only for core services (service=com.jetbrains.rdserver.statistics.BackendStatisticsManager, plugin=com.jetbrains.codeWithMe)

2024-05-03 09:22:47,556 [    759]   WARN - #c.i.s.ComponentManagerImpl - com.intellij.psi.search.FilenameIndex initializer requests com.intellij.ide.plugins.PluginUtil instance



   * 


3.2. LangServe에서 Ollama 체인 생성

3.2.1. Run - langserve

* app 폴더 진입 후 server.py 실행 

   * python server.py

[lds@llm ~]$ cd /home/lds/Works/llm/

[lds@llm llm]$ source env/bin/activate

(env) [lds@llm llm]$ cd app/

(env) [lds@llm app]$ pwd

/home/lds/Works/llm/app

(env) [lds@llm app]$ python server.py

(env) [lds@llm app]$ python server.py

INFO:     Started server process [2043]

INFO:     Waiting for application startup.



 __          ___      .__   __.   _______      _______. _______ .______     ____    ____  _______

|  |        /   \     |  \ |  |  /  _____|    /       ||   ____||   _  \    \   \  /   / |   ____|

|  |       /  ^  \    |   \|  | |  |  __     |   (----`|  |__   |  |_)  |    \   \/   /  |  |__

|  |      /  /_\  \   |  . `  | |  | |_ |     \   \    |   __|  |      /      \      /   |   __|

|  `----./  _____  \  |  |\   | |  |__| | .----)   |   |  |____ |  |\  \----.  \    /    |  |____

|_______/__/     \__\ |__| \__|  \______| |_______/    |_______|| _| `._____|   \__/     |_______|



LANGSERVE: Playground for chain "/prompt/" is live at:

LANGSERVE:  │

LANGSERVE:  └──> /prompt/playground/

LANGSERVE:

LANGSERVE: Playground for chain "/llm/" is live at:

LANGSERVE:  │

LANGSERVE:  └──> /llm/playground/

LANGSERVE:

LANGSERVE: Playground for chain "/xionic/" is live at:

LANGSERVE:  │

LANGSERVE:  └──> /xionic/playground/

LANGSERVE:

LANGSERVE: Playground for chain "/chat/" is live at:

LANGSERVE:  │

LANGSERVE:  └──> /chat/playground/

LANGSERVE:

LANGSERVE: Playground for chain "/translate/" is live at:

LANGSERVE:  │

LANGSERVE:  └──> /translate/playground/

LANGSERVE:

LANGSERVE: See all available routes at /docs/

   * 


3.3. Check - Browser

3.3.1. LangServe

* Browser

   * http://192.168.50.130:8000

      * http://192.168.50.130:8000/xionic/playground/

  




3.3.2. Fast API

* Browser

   * http://192.168.50.130:8000/docs#/


 

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

회사명 : (주)리눅스데이타시스템
대표이사 : 정정모
본사 : 강남구 봉은사로 114길 40 홍선빌딩 2층
- tel : 02-6207-1160
대전지사 : 유성구 노은로174 도원프라자 5층
- tel : 042-331-1161

접속자집계

오늘
1,288
어제
1,596
최대
3,935
전체
1,065,477
Copyright © www.linuxdata.org All rights reserved.