Skip to content

Commit

Permalink
docs: add installation note for extensions (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas2D authored Jan 26, 2024
1 parent e120414 commit 83d7409
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 5 deletions.
6 changes: 6 additions & 0 deletions examples/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
Use large language models with your favourite framework, like LangChain / LLamaIndex or Transformers (HuggingFace).
If you want to use your model but still use the SDK, try the LocalServer extension provided by the SDK.
.. admonition:: Before you start
:class: important
To use one of the following extensions, first install it by running
:bash:`pip install 'ibm-generative-ai[extension_name]'` (the extension name is always lower-cased).
"""
6 changes: 6 additions & 0 deletions examples/extensions/huggingface/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Transformers (HuggingFace)
.. admonition:: Before you start
:class: important
To use the following extension, first install it by running
:bash:`pip install 'ibm-generative-ai[huggingface]'`.
"""
6 changes: 6 additions & 0 deletions examples/extensions/langchain/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
LangChain
.. admonition:: Before you start
:class: important
To use the following extension, first install it by running
:bash:`pip install 'ibm-generative-ai[langchain]'`.
"""
6 changes: 6 additions & 0 deletions examples/extensions/llama_index/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
LLamaIndex
.. admonition:: Before you start
:class: important
To use the following extension, first install it by running
:bash:`pip install 'ibm-generative-ai[llama-index]'`.
"""
6 changes: 6 additions & 0 deletions examples/extensions/localserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
LocalServer
Create a minimal Rest API compatible with the SDK interface and run inference on your model.
.. admonition:: Before you start
:class: important
To use the following extension, first install it by running
:bash:`pip install 'ibm-generative-ai[localserver]'`.
"""
1 change: 1 addition & 0 deletions src/genai/extensions/langchain/chat_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class LangChainChatInterface(BaseChatModel):
from genai import Client, Credentials
from genai.extensions.langchain import LangChainChatInterface
from langchain_core.messages import HumanMessage, SystemMessage
from genai.text.generation import TextGenerationParameters
client = Client(credentials=Credentials.from_env())
llm = LangChainChatInterface(
Expand Down
1 change: 1 addition & 0 deletions src/genai/extensions/langchain/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class LangChainInterface(LLM):
from genai import Client, Credentials
from genai.extensions.langchain import LangChainInterface
from genai.text.generation import TextGenerationParameters
client = Client(credentials=Credentials.from_env())
llm = LangChainInterface(
Expand Down
11 changes: 6 additions & 5 deletions src/genai/text/embedding/embedding_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ def create(
client = Client(credentials=Credentials.from_env())
# Create a new conversation
response = client.text.embedding.create(
model_id="sentence-transformers/all-minilm-l6-v2",
input="Write a tagline for an alumni association: Together we"
responses = list(
client.text.embedding.create(
model_id="sentence-transformers/all-minilm-l6-v2",
input="Write a tagline for an alumni association: Together we"
)
)
print("Output vectors", response.results)
print("Output vector", responses[0].results[0])
Yields:
TextEmbeddingCreateResponse object.
Expand Down

0 comments on commit 83d7409

Please sign in to comment.