Browse Source

Update 'README.md'

天问 2 years ago
parent
commit
f51ec826a5
1 changed files with 32 additions and 1 deletions
  1. 32 1
      README.md

+ 32 - 1
README.md

@@ -1,3 +1,34 @@
 # llama_index
 # llama_index
 
 
-LlamaIndex (GPT Index) is a project that provides a central interface to connect your LLM's with external data.
+LlamaIndex (GPT Index) is a project that provides a central interface to connect your LLM's with external data.
+
+文档:
+
+https://gpt-index.readthedocs.io/en/latest/
+
+
+To build a simple vector store index:
+
+```
+import os
+os.environ["OPENAI_API_KEY"] = 'YOUR_OPENAI_API_KEY'
+
+from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader
+documents = SimpleDirectoryReader('data').load_data()
+index = GPTSimpleVectorIndex(documents)
+```
+
+To save to and load from disk:
+
+```
+# save to disk
+index.save_to_disk('index.json')
+# load from disk
+index = GPTSimpleVectorIndex.load_from_disk('index.json')
+```
+
+To query:
+
+```
+index.query("<question_text>?")
+```