llama - create 도구
사용
프로젝트 만들기
npx create-llama@latest
✔ Which template would you like to use? › Chat
✔ Which framework would you like to use? › FastAPI (Python)
✔ Would you like to generate a NextJS frontend for your FastAPI (Python) backend? … No
✔ Which model would you like to use? › gpt-3.5-turbo-0125
✔ Which embedding model would you like to use? › text-embedding-3-small
✔ Which data source would you like to use? › Use an example PDF
✔ Would you like to add another data source? › No
✔ Would you like to use LlamaParse (improved parser for RAG - requires API key)? … yes
✔ Please provide your LlamaIndex Cloud API key (leave blank to skip): …
✔ Would you like to use a vector database? › PostgreSQL
SU PA B ASE 에서 데이터 베이 스를 생성 하고 M igration connection string 을 가져 옵니다 .
. en v 파일
Cond as 환경 으로 전환
에이 전 트로 전환
py pro ject . tom l
의 라이 브 러 리 버 전을 업데이트 합니다 .
[tool]
[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = [ "Marcus Schiesser <mail@marcusschiesser.de>" ]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11,<3.12"
fastapi = "^0.110.1"
python-dotenv = "^1.0.0"
llama-index = "0.10.28"
llama-index-core = "0.10.28"
llama-index-agent-openai = "0.2.2"
[tool.poetry.dependencies.uvicorn]
extras = [ "standard" ]
version = "^0.29.0"
[tool.poetry.dependencies.llama-index-vector-stores-postgres]
version = "^0.1.1"
[tool.poetry.dependencies.llama-index-vector-stores-pinecone]
version = "^0.1.3"
[tool.poetry.dependencies.docx2txt]
version = "^0.8"
[build-system]
requires = [ "poetry-core" ]
build-backend = "poetry.core.masonry.api"
패키 지 관리 자
Po et ry 를 사용 하지만 Po et ry Inst all 은 항상 Po et ry 의 가상 환경을 사용 하므로 문제가 발생 하기 쉽습니다 .
pip 를 사용하여 설치 하면 오류 가 발생 하지 않습니다 .
pip install .
인 덱 스 생성
python app/engine/generate.py
text - emb edding - 3 - large 를 사용하면 오류 가 발생합니다 .
File "/Users/yanghaibin/anaconda3/envs/LI311-b/lib/python3.11/site-packages/pgvector/utils/__init__.py", line 35, in to_db
raise ValueError('expected %d dimensions, not %d' % (dim, len(value)))
sqlalchemy.exc.StatementError: (builtins.ValueError) expected 1536 dimensions, not 3072
환경 변경 사항 이 업데이트 되지 않으며 새 명령 줄 창 이 열 립니다 .
렌 더 로 배 포
기본 값 을 유지 하기 위해 컴 파 일 : poet ry install
main.py运行:python
프로젝트 예 제 - 읽기 : Python - Fast API
소 스 디 렉 토 리
media _ type = " text / pla in " 을 ' text / event - stream ' 로 변경 해야 하지만 Post man 을 사용하면 문제가 있습니다 .
return Stre aming Res ponse (ev ent _ generator (), media _ type =" text / pla in ")