Fireworks Class — langchain Architecture
Architecture documentation for the Fireworks class in llms.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4dfba76d_967f_bdbe_e65a_3ddf00dc8892["Fireworks"] b2c7d2a5_0852_93df_c3e1_828c36a88999["LLM"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|extends| b2c7d2a5_0852_93df_c3e1_828c36a88999 0f85ca17_639e_b06e_0491_31848cf61d49["llms.py"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|defined in| 0f85ca17_639e_b06e_0491_31848cf61d49 8f746f89_231f_9680_9047_7f3d2301bcb8["build_extra()"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|method| 8f746f89_231f_9680_9047_7f3d2301bcb8 98836941_780a_4524_6d7f_80d7d0ba5439["_llm_type()"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|method| 98836941_780a_4524_6d7f_80d7d0ba5439 8d4f4229_b5de_0a63_174b_10061594c160["_format_output()"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|method| 8d4f4229_b5de_0a63_174b_10061594c160 7bad267b_ba0e_78e8_75b4_6943c1f9cdf3["get_user_agent()"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|method| 7bad267b_ba0e_78e8_75b4_6943c1f9cdf3 8ab331cc_bf60_5f59_a532_b4011886ba15["default_params()"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|method| 8ab331cc_bf60_5f59_a532_b4011886ba15 26ae2aaf_8fa1_b5b1_7053_5c4fcf4abcbf["_call()"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|method| 26ae2aaf_8fa1_b5b1_7053_5c4fcf4abcbf 1b16bd3c_3c6a_1003_7ff4_901808dc90d7["_acall()"] 4dfba76d_967f_bdbe_e65a_3ddf00dc8892 -->|method| 1b16bd3c_3c6a_1003_7ff4_901808dc90d7
Relationship Graph
Source Code
libs/partners/fireworks/langchain_fireworks/llms.py lines 24–233
class Fireworks(LLM):
"""LLM models from `Fireworks`.
To use, you'll need an [API key](https://fireworks.ai). This can be passed in as
init param `fireworks_api_key` or set as environment variable
`FIREWORKS_API_KEY`.
[Fireworks AI API reference](https://readme.fireworks.ai/)
Example:
```python
response = fireworks.generate(["Tell me a joke."])
```
"""
base_url: str = "https://api.fireworks.ai/inference/v1/completions"
"""Base inference API URL."""
fireworks_api_key: SecretStr = Field(
alias="api_key",
default_factory=secret_from_env(
"FIREWORKS_API_KEY",
error_message=(
"You must specify an api key. "
"You can pass it an argument as `api_key=...` or "
"set the environment variable `FIREWORKS_API_KEY`."
),
),
)
"""Fireworks API key.
Automatically read from env variable `FIREWORKS_API_KEY` if not provided.
"""
model: str
"""Model name. [(Available models)](https://readme.fireworks.ai/)"""
temperature: float | None = None
"""Model temperature."""
top_p: float | None = None
"""Used to dynamically adjust the number of choices for each predicted token based
on the cumulative probabilities. A value of `1` will always yield the same output.
A temperature less than `1` favors more correctness and is appropriate for
question answering or summarization. A value greater than `1` introduces more
randomness in the output.
"""
model_kwargs: dict[str, Any] = Field(default_factory=dict)
"""Holds any model parameters valid for `create` call not explicitly specified."""
top_k: int | None = None
"""Used to limit the number of choices for the next predicted word or token. It
specifies the maximum number of tokens to consider at each step, based on their
probability of occurrence. This technique helps to speed up the generation process
and can improve the quality of the generated text by focusing on the most likely
options.
"""
max_tokens: int | None = None
"""The maximum number of tokens to generate."""
repetition_penalty: float | None = None
"""A number that controls the diversity of generated text by reducing the likelihood
of repeated sequences. Higher values decrease repetition.
"""
logprobs: int | None = None
"""An integer that specifies how many top token log probabilities are included in
the response for each token generation step.
"""
timeout: int | None = 30
"""Timeout in seconds for requests to the Fireworks API."""
model_config = ConfigDict(
extra="forbid",
populate_by_name=True,
)
@model_validator(mode="before")
@classmethod
def build_extra(cls, values: dict[str, Any]) -> Any:
"""Build extra kwargs from additional params that were passed in."""
all_required_field_names = get_pydantic_field_names(cls)
return _build_model_kwargs(values, all_required_field_names)
@property
def _llm_type(self) -> str:
"""Return type of model."""
return "fireworks"
Extends
Source
Frequently Asked Questions
What is the Fireworks class?
Fireworks is a class in the langchain codebase, defined in libs/partners/fireworks/langchain_fireworks/llms.py.
Where is Fireworks defined?
Fireworks is defined in libs/partners/fireworks/langchain_fireworks/llms.py at line 24.
What does Fireworks extend?
Fireworks extends LLM.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free