Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix context_window=None for llm metadata #17029

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/docs/examples/llm/sambanovasystems.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"\n",
"llm = SambaNovaCloud(\n",
" model=\"Meta-Llama-3.1-70B-Instruct\",\n",
" context_window=100000,\n",
" max_tokens=1024,\n",
" temperature=0.7,\n",
" top_k=1,\n",
Expand Down Expand Up @@ -397,6 +398,7 @@
"\n",
"llm = SambaStudio(\n",
" model=\"Meta-Llama-3-70B-Instruct-4096\",\n",
" context_window=100000,\n",
" max_tokens=1024,\n",
" temperature=0.7,\n",
" top_k=1,\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ def class_name(cls) -> str:
def metadata(self) -> LLMMetadata:
"""LLM metadata."""
return LLMMetadata(
context_window=None,
num_output=None,
context_window=self.context_window,
num_output=self.max_new_tokens,
model_name=self.model_name,
is_chat_model=self.is_chat_model,
is_chat_model=False,
)

@llm_completion_callback()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-llms-modelscope"
readme = "README.md"
version = "0.4.0"
version = "0.4.1"

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SambaNovaCloud(
sambanova_url="SambaNova cloud endpoint URL",
sambanova_api_key="set with your SambaNova cloud API key",
model="model name",
context_window=100000,
)
```

Expand All @@ -37,5 +38,6 @@ SambaStudio(
sambastudio_url="SambaStudio endpoint URL",
sambastudio_api_key="set with your SambaStudio endppoint API key",
model="model name",
context_window=100000,
)
```
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class SambaNovaCloud(LLM):
top_p = model top p,
top_k = model top k,
stream_options = include usage to get generation metrics
context_window = model context window
)
Complete:
.. code-block:: python
Expand Down Expand Up @@ -185,6 +186,8 @@ class SambaNovaCloud(LLM):
description="Whether to use streaming handler when using non streaming methods",
)

context_window: int = Field(default=4096, description="context window")

max_tokens: int = Field(default=1024, description="max tokens to generate")

temperature: float = Field(default=0.7, description="model temperature")
Expand All @@ -205,7 +208,7 @@ def class_name(cls) -> str:
@property
def metadata(self) -> LLMMetadata:
return LLMMetadata(
context_window=None,
context_window=self.context_window,
num_output=self.max_tokens,
is_chat_model=True,
model_name=self.model,
Expand Down Expand Up @@ -659,6 +662,7 @@ class SambaStudio(LLM):
model = model or expert name (set for CoE endpoints),
max_tokens = max number of tokens to generate,
temperature = model temperature,
context_window = model context window,
top_p = model top p,
top_k = model top k,
do_sample = whether to do sample
Expand All @@ -679,6 +683,8 @@ class SambaStudio(LLM):
Whether to use streaming
max_tokens: inthandler when using non streaming methods
max tokens to generate
context_window: int
model context window
temperature: float
model temperature
top_p: float
Expand Down Expand Up @@ -715,6 +721,7 @@ class SambaStudio(LLM):
model = model or expert name (set for CoE endpoints),
max_tokens = max number of tokens to generate,
temperature = model temperature,
context_window = model context window,
top_p = model top p,
top_k = model top k,
do_sample = whether to do sample
Expand Down Expand Up @@ -797,6 +804,8 @@ class SambaStudio(LLM):
description="Whether to use streaming handler when using non streaming methods",
)

context_window: int = Field(default=4096, description="context window")

max_tokens: int = Field(default=1024, description="max tokens to generate")

temperature: Optional[float] = Field(default=0.7, description="model temperature")
Expand Down Expand Up @@ -840,7 +849,7 @@ def class_name(cls) -> str:
@property
def metadata(self) -> LLMMetadata:
return LLMMetadata(
context_window=None,
context_window=self.context_window,
num_output=self.max_tokens,
is_chat_model=True,
model_name=self.model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ authors = ["Rodrigo Maldonado <rodrigo.maldonado@pucp.edu.pe>"]
description = "llama-index llms sambanova cloud and sambastudio integration"
name = "llama-index-llms-sambanovasystems"
readme = "README.md"
version = "0.4.0"
version = "0.4.1"

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
Expand Down
Loading