openai elasticsearch rag
1.0.0
OpenAI 및 ElasticSearch를 사용하여 긴 형식의 텍스트로 Q & A를 제공하는 Rag (검색 세대 생성) 응용 프로그램. 여기 우리가 있습니다
python -m venv venv source venv/bin/activatepip install -r requirements.txtpython -m spacy download en_core_web_smbin/elasticsearch (또는 binelasticsearch.bat 에서 Windows) 시작하십시오.curl -X GET "localhost:9200/" 앱을 실행하기 전에 .env-template 사용하여 .env 파일을 작성하고 OpenAI API 키 및 Elasticsearch 자격 증명을 추가하십시오.
python run.py 앱은 포트 8081 의 localhost 에서 시작됩니다. 터미널에서 실행하여 정신 점검. Hello Message를 반환해야합니다.
curl -X GET " localhost:8081 " curl --location --request PUT ' http://localhost:9200/first-index '
--header ' Content-Type: application/json '
--data-raw ' {
"mappings": {
"properties": {
"text": {
"type": "text"
},
"embedding": {
"type": "dense_vector",
"dims": 1536
}
}
}
} 'Clean Start를 위해 인덱스를 삭제하려면 다음 명령을 사용하십시오.
curl --location --request DELETE ' http://localhost:9200/first-index ' 데이터를 색인하려면 다음 curl 명령을 사용하십시오. 이 명령은 지정된 엔드 포인트에 포스트 요청을 보낼 텍스트와 색인 이름을 포함하는 JSON 페이로드와 함께 보냅니다.
포트 8081 의 localhost 에서 서버가 실행되는지 확인하십시오.
curl --location --request POST ' localhost:8081/api/index '
--header ' Content-Type: application/json '
--data-raw ' {
"text": "Ajeet is an engineer turned product entrepreneur with experience in AI, SaaS, HealthTech and EdTech. He is a technology enthusiast and loves to work on new technologies. He was a founding member of leading health-tech startups HealthKart and TATA 1mg in India. He was the founder of Joe Hukum, a chatbot platform which was acquired by Freshworks. After Freshworks, he founded Seekho.ai to solve for the skill gap in Indian higher education. Currently, he is on a break and is exploring GenAI to solve for the next meaningful problem. He is passionate about solving zero to one problems and building products that can impact millions of lives.",
"index_name": "first-index"
} 'Example 1:
curl --location --request POST ' localhost:8081/api/query '
--header ' Content-Type: application/json '
--data-raw ' {
"question": "Who is Ajeet?",
"index_name": "first-index"
} 'Example 2:
curl --location --request POST ' localhost:8081/api/query '
--header ' Content-Type: application/json '
--data-raw ' {
"question": "Joe Hukum was acquired by which company?",
"index_name": "first-index"
} '