langchain/libs/partners
back2nix a1614b88ac
groq[patch]: groq proxy support (#20758)
# Proxy Fix for Groq Class 🐛 🚀

## Description
This PR fixes a bug related to proxy settings in the `Groq` class,
allowing users to connect to LangChain services via a proxy.

## Changes Made
-  FIX support for specifying proxy settings in the `Groq` class.
-  Resolved the bug causing issues with proxy settings.
-  Did not include unit tests and documentation updates.
-  Did not run make format, make lint, and make test to ensure code
quality and functionality because I couldn't get it to run, so I don't
program in Python and couldn't run `ruff`.
-  Ensured that the changes are backwards compatible.
-  No additional dependencies were added to `pyproject.toml`.

### Error Before Fix
```python
Traceback (most recent call last):
  File "/home/bg/Documents/code/github.com/back2nix/test/groq/main.py", line 9, in <module>
    chat = ChatGroq(
           ^^^^^^^^^
  File "/home/bg/Documents/code/github.com/back2nix/test/groq/venv310/lib/python3.11/site-packages/langchain_core/load/serializable.py", line 120, in __init__
    super().__init__(**kwargs)
  File "/home/bg/Documents/code/github.com/back2nix/test/groq/venv310/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for ChatGroq
__root__
  Invalid `http_client` argument; Expected an instance of `httpx.AsyncClient` but got <class 'httpx.Client'> (type=type_error)
  ```
  
### Example usage after fix
  ```python3
import os

import httpx
from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq

chat = ChatGroq(
    temperature=0,
    groq_api_key=os.environ.get("GROQ_API_KEY"),
    model_name="mixtral-8x7b-32768",
    http_client=httpx.Client(
        proxies="socks5://127.0.0.1:1080",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
    http_async_client=httpx.AsyncClient(
        proxies="socks5://127.0.0.1:1080",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

system = "You are a helpful assistant."
human = "{text}"
prompt = ChatPromptTemplate.from_messages([("system", system), ("human", human)])

chain = prompt | chat
out = chain.invoke({"text": "Explain the importance of low latency LLMs"})

print(out)
```

---------

Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2024-04-24 21:58:03 +00:00
..
ai21 standard tests: add xfails (#20659) 2024-04-23 17:14:16 -04:00
airbyte airbyte[patch]: release 0.1.1, python 3.9 compat (#18597) 2024-03-05 19:22:08 +00:00
anthropic docs, multiple: de-beta with_structured_output (#20850) 2024-04-24 19:34:57 +00:00
chroma chroma: release 0.1.0 (#20355) 2024-04-11 12:39:52 -07:00
exa patch: deprecate (a)get_relevant_documents (#20477) 2024-04-22 11:14:53 -04:00
fireworks docs, multiple: de-beta with_structured_output (#20850) 2024-04-24 19:34:57 +00:00
groq groq[patch]: groq proxy support (#20758) 2024-04-24 21:58:03 +00:00
ibm ibm: Add support for Embedding Models (#20647) 2024-04-19 20:56:24 +00:00
mistralai docs, multiple: de-beta with_structured_output (#20850) 2024-04-24 19:34:57 +00:00
mongodb community[patch], mongodb[patch]: Stop spamming SIMD import warnings (#19531) 2024-03-28 03:11:02 +00:00
nomic partners: version constraints (#17492) 2024-02-14 08:57:46 -08:00
openai docs, multiple: de-beta with_structured_output (#20850) 2024-04-24 19:34:57 +00:00
pinecone pinecone[patch]: fix core min version (#20177) 2024-04-08 20:06:59 +00:00
robocorp robocorp[patch]: fix core min version (#19879) 2024-04-01 11:34:14 -07:00
together update scheduled tests (#20526) 2024-04-16 16:49:46 -04:00
upstage upstage[patch]: un-xfail tool calling test, release 0.1.0 (#20635) 2024-04-19 02:02:21 +00:00
voyageai voyageai[patch]: top level reranker import (#19645) 2024-03-28 06:37:55 +00:00
astradb.md infra: rm sep repo partner dirs (#20756) 2024-04-22 14:05:39 -07:00
cohere.md infra: rm sep repo partner dirs (#20756) 2024-04-22 14:05:39 -07:00
elasticsearch.md infra: rm sep repo partner dirs (#20756) 2024-04-22 14:05:39 -07:00
google_genai.md infra: rm sep repo partner dirs (#20756) 2024-04-22 14:05:39 -07:00
google_vertexai.md infra: rm sep repo partner dirs (#20756) 2024-04-22 14:05:39 -07:00
nvidia_ai_endpoints.md infra: rm sep repo partner dirs (#20756) 2024-04-22 14:05:39 -07:00
nvidia_trt.md infra: rm sep repo partner dirs (#20756) 2024-04-22 14:05:39 -07:00