Skip to content

Commit

Permalink
feat: add llamaindex completion example
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Dec 1, 2024
1 parent 25a703d commit 815ddbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions interweb-server/src/test/python/env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dependencies:
- langchain-openai
- llama-index
- llama-index-embeddings-openai
- llama-index-llms-openai-like
12 changes: 12 additions & 0 deletions interweb-server/src/test/python/llamaindex_client.test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import os
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.llms.openai_like import OpenAILike
from llama_index.core.llms import ChatMessage, MessageRole

os.environ["OPENAI_API_BASE"] = os.getenv("INTERWEB_HOST", "https://interweb.l3s.uni-hannover.de/v1")
os.environ["OPENAI_API_KEY"] = os.getenv("INTERWEB_APIKEY")

# Create a completion
llm = OpenAILike(model="llama3.1:8b", is_chat_model=True) # gpt-4o-mini

resp = llm.chat([
ChatMessage(role=MessageRole.SYSTEM, content="Always answer the question, even if the context isn't helpful."),
ChatMessage(role=MessageRole.USER, content="What is your mission?"),
])
print(resp)

# Get Embeddings
embed_model = OpenAIEmbedding(
model_name="bge-m3:567m"
)
Expand Down

0 comments on commit 815ddbc

Please sign in to comment.