Skip to content

Commit

Permalink
Update LlamaIndex RAG tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi03071991 committed Jul 23, 2024
1 parent 4cbc770 commit ef174b9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions docs/guides/basic-RAG.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,10 @@ Visit our [community cookbook example](https://github.com/mistralai/cookbook/blo
**Code:**

```python
from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.llms import MistralAI
from llama_index.embeddings import MistralAIEmbedding
from llama_index import ServiceContext
from llama_index.query_engine import RetrieverQueryEngine
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.llms.mistralai import MistralAI
from llama_index.embeddings.mistralai import MistralAIEmbedding
from llama_index.core import Settings

# Load data
reader = SimpleDirectoryReader(input_files=["essay.txt"])
Expand All @@ -235,10 +234,10 @@ documents = reader.load_data()
# Define LLM and embedding model
llm = MistralAI(api_key=api_key, model="mistral-medium")
embed_model = MistralAIEmbedding(model_name="mistral-embed", api_key=api_key)
service_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)

Settings.llm = llm
Settings.embed_model = embed_model
# Create vector store index
index = VectorStoreIndex.from_documents(documents, service_context=service_context)
index = VectorStoreIndex.from_documents(documents)

# Create query engine
query_engine = index.as_query_engine(similarity_top_k=2)
Expand Down

0 comments on commit ef174b9

Please sign in to comment.