Skip to content

Commit

Permalink
community: fix an issue with deepinfra integration (#28715)
Browse files Browse the repository at this point in the history
Thank you for contributing to LangChain!

- [x] **PR title**: langchain: add URL parameter to ChatDeepInfra class

- [x] **PR message**: add URL parameter to ChatDeepInfra class
- **Description:** This PR introduces a url parameter to the
ChatDeepInfra class in LangChain, allowing users to specify a custom
URL. Previously, the URL for the DeepInfra API was hardcoded to
"https://stage.api.deepinfra.com/v1/openai/chat/completions", which
caused issues when the staging endpoint was not functional. The _url
method was updated to return the value from the url parameter, enabling
greater flexibility and addressing the problem. out!

---------

Co-authored-by: Erick Friis <[email protected]>
  • Loading branch information
JustNawaf and efriis authored Dec 14, 2024
1 parent 008efad commit decd77c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libs/community/langchain_community/chat_models/deepinfra.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ class ChatDeepInfra(BaseChatModel):
# client: Any #: :meta private:
model_name: str = Field(default="meta-llama/Llama-2-70b-chat-hf", alias="model")
"""Model name to use."""

url: str = "https://api.deepinfra.com/v1/openai/chat/completions"
"""URL to use for the API call."""

deepinfra_api_token: Optional[str] = None
request_timeout: Optional[float] = Field(default=None, alias="timeout")
temperature: Optional[float] = 1
Expand Down Expand Up @@ -469,7 +473,7 @@ def _handle_status(self, code: int, text: Any) -> None:
)

def _url(self) -> str:
return "https://stage.api.deepinfra.com/v1/openai/chat/completions"
return self.url

def _headers(self) -> Dict:
return {
Expand Down

0 comments on commit decd77c

Please sign in to comment.