delayedkarma/langchain-issues huggingface dataset:
Azure function not working - openai error with latest builds
Labels: name: auto:bug, name: area: models

### System Info

Name: langchain
Version: 0.0.352

Name: openai
Version: 1.6.1



### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [X] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

from langchain.chat_models import AzureChatOpenAI
from langchain.schema import HumanMessage

BASE_URL = "https://resource.openai.azure.com/"
API_KEY = "abc123"
DEPLOYMENT_NAME = "GPT35"

model = AzureChatOpenAI(
    openai_api_base=BASE_URL,
    openai_api_version="2023-05-15",
    deployment_name=DEPLOYMENT_NAME,
    openai_api_key=API_KEY,
    openai_api_type="azure",
)

print(model(
    [
        HumanMessage(
            content="Translate this sentence from English to French. I love programming."
        )
    ]
))

### Expected behavior

I get an error about openai module.  I get same error when i try and use embeddings.
I can use the openai azure pythons fine with my resource and api key - but langchain is broken.

AttributeError                            Traceback (most recent call last)
AttributeError: module 'openai' has no attribute 'error'
Make all json parsing less strict by default
Labels: name: auto:improvement, name: area: langserve, name: size:XS

- Enables strict=False by default
- Uses partial json recovery logic by default

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes if applicable,
  - **Dependencies:** any dependencies required for this change,
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
Incorrect Snowflake SQL dialect in SQLDatabaseChain 
Labels: name: auto:bug, name: area: models

### System Info

langchain version: 0.0.348
Python 3.9.18
Mac OS M2 (Ventura 13.6.2)
AWS Bedrock Titan text express, Claude v2

### Who can help?

@hwchase17
@agola11

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [X] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

SQLDatabaseChain produces SQL query where the logic is correct but uses double quotes "identifier" hence incorrect for the snowflake SQL which require single quotes 'identifier'
output = SQL: SELECT "company" = "ABC"
desired output = SQL: SELECT 'company' = 'ABC'requires

### Expected behavior

desired out should be snowflake SQL single quotes for the identifier 'ABC'
AWS bedrock Claude v2 SQLDatabaseChain produces comments before the SQL Query
Labels: name: auto:bug, name: area: models, name: integration: aws

### System Info

langchain Version: 0.0.348
python Version: Python 3.9.18
OS: Mac OS M2 (Ventura 13.6.2)

### Who can help?

@hwchase17
@agola11

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

llm = Bedrock(
    credentials_profile_name= os.environ.get('profile_name'),
    model_id="anthropic.claude-v2",
    model_kwargs={"temperature": 0.1},
    endpoint_url="https://bedrock-runtime.us-east-1.amazonaws.com",
    region_name="us-east-1",
    verbose=True
)

db = SQLDatabase.from_uri(snowflake_url, sample_rows_in_table_info=3, include_tables=["table_name"])
output= SQLDatabaseChain.from_llm(
        llm,
        db, 
        prompt=few_shot_prompt,
        return_intermediate_steps=True,
        )
Gives the following error:
Error: syntax error line 1 at position 0 unexpected '**The**'.
[SQL: **The** query looks good to me, I don't see any of the common mistakes listed. Here is the original query again: SELECT *
FROM table]

### Expected behavior

the output should only produce SQL query outputted plainly, should not surround it in quotes or any comments prior to the SQL Query 
Desired output: 
[SQL: SELECT *
FROM table]
mistralai[minor]: Add embeddings
Labels: name: lgtm, name: area: embeddings, name: auto:enhancement, name: size:L, name: partner

- **Description:** Adds MistralAIEmbeddings class for embeddings, using the new official API.
- **Dependencies:** mistralai
- **Tag maintainer**: @efriis, @hwchase17
- **Twitter handle:** @LMS_David_RS

Create `integrations/text_embedding/mistralai.ipynb`: an example notebook for MistralAIEmbeddings class
Modify `embeddings/__init__.py`: Import the class
Create `embeddings/mistralai.py`: The embedding class
Create `integration_tests/embeddings/test_mistralai.py`: The test file.
[langchain] agents code changes
Labels: name: area: agent, name: auto:improvement, name: size:XL

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes if applicable,
  - **Dependencies:** any dependencies required for this change,
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!
Update vectorstore_retriever_memory.mdx
Labels: name: area: memory, name: auto:documentation, name: size:XS

removed bad comments

<!-- Thank you for contributing to LangChain!

Please title your PR "<package>: <description>", where <package> is whichever of langchain, community, core, experimental, etc. is being modified.

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes if applicable,
  - **Dependencies:** any dependencies required for this change,
  - **Twitter handle:** we announce bigger features on Twitter. If your PR gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` from the root of the package you've modified to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/

If you're adding a new integration, please include:
  1. a test for the integration, preferably unit tests that do not rely on network access,
  2. an example notebook showing its use. It lives in `docs/docs/integrations` directory.

If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17.
 -->
community: llms.vertexai - Adds support for logprobs
Labels: name: auto:improvement, name: area: models, name: size:S



  - **Description:** Adds support for logprobs within vertex ai, recently google started to support logprobs, this commit includes fast adaptation, Google recently started supporting logprobs, please check out this [page](https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/text#generative-ai-text-prompt-python_vertex_ai_sdk) for more details on their side.
  - **Issue:** -,
  - **Dependencies:** -,
  - **Twitter handle:** [Burak Ömür](https://twitter.com/burkomr)
OpenAIAssistantRunnable stuck on execution with langchain tools
Labels: name: area: agent, name: auto:bug

### System Info

```
from langchain.tools import DuckDuckGoSearchRun
from langchain.agents.openai_assistant import OpenAIAssistantRunnable
from langchain.agents import AgentExecutor

tools = [DuckDuckGoSearchRun()]
assistant = OpenAIAssistantRunnable.create_assistant(
        name="langchain assistant",
        instructions="You are a personal math tutor.",
        tools=tools,
        model="gpt-4-1106-preview",
        as_agent=True,
    )
   
    logger.debug(assistant)
    logger.debug(assistant.assistant_id)
    agent_executor = AgentExecutor(agent=assistant, tools=tools,verbose=True)
    response =  agent_executor.invoke({"content": "whats the whether in london"})
    print(response)
    logger.debug(response)
```

I am trying to run the following from the example. It prints out the assitant information and id but after that it get completely stuck. I tried to step through the debugger but after while it continues and never comes back after calling 


```
callback_manager = CallbackManager.configure(
            callbacks,
            self.callbacks,
            self.verbose,
            tags,
            self.tags,
            metadata,
            self.metadata,
        )
```

in the `__call__` method

### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [X] Callbacks/Tracing
- [ ] Async

### Reproduction

from langchain.tools import DuckDuckGoSearchRun
from langchain.agents.openai_assistant import OpenAIAssistantRunnable
from langchain.agents import AgentExecutor

tools = [DuckDuckGoSearchRun()]
assistant = OpenAIAssistantRunnable.create_assistant(
        name="langchain assistant",
        instructions="You are a personal math tutor.",
        tools=tools,
        model="gpt-4-1106-preview",
        as_agent=True,
    )
   
    logger.debug(tai_assistant)
    logger.debug(tai_assistant.assistant_id)
    agent_executor = AgentExecutor(agent=assistant, tools=tools,verbose=True)
    response =  agent_executor.invoke({"content": "whats the whether in london"})
    print(response)
    logger.debug(response)

### Expected behavior

to have an output from the agent and not be stuck
[mistralai]: Don´t support stop sequence
Labels: name: auto:bug, name: area: models

### System Info

Python: 3.11
Langchain: 0.0.352
mistralai: 0.0.8

### Who can help?

@efriis 

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [X] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

If the ChatMistralAI model is used for an agent or similar, an error appears because the official Mistral API does not currently support the stop parameter (as other APIs such as OpenAI do).

### Expected behavior

Although this is something that should be fixed by Mistral in its official API, one of the following options should be done:
- Warn the user that this model cannot be used with a stop sequence before breaking execution due to the error.
- Implement an own solution for the stop sequence in the same package and do not send that parameter to the official client call.
langchain: Fix class name in RetryOutputParser docstring
Labels: name: lgtm, name: area: doc loader, name: auto:nit, name: size:XS

`OutputFixingParser` -> `RetryOutputParser`


![i'm-helping](https://github.com/langchain-ai/langchain/assets/5986636/68f1b8ce-8a6e-4e75-9cf8-e3c93ac562c2)
community: Support openai_proxy compatible with openai>1.0.0
Labels: name: auto:improvement, name: area: models, name: size:L

 ### **Description:** 

`openai` v1 no longer supports the method of setting `openai.proxy`. If using `OPENAI_PRPXY`, the users need to initialize an `http_client`.

 ### **Issue:**

https://github.com/langchain-ai/langchain/issues/13939
Manipulating database using chatgpt 
Labels: name: auto:question, name: area: models

### System Info

Is there any way to manipulate the data in database like update, insert, delete through chatgpt chatbot with openai and langchain?


### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

Is there any way to manipulate the data in database like update, insert, delete through chatgpt chatbot with openai and langchain?

### Expected behavior

possibility of  manipulate the data in database like update, insert, delete through chatgpt chatbot with openai and langchain?
community: Make doctran synchronous 
Labels: name: area: doc loader, name: auto:documentation, name: size:L

### Description

I found that the methods in [the doctran library](https://github.com/psychic-api/doctran) have been restructured into [synchronized versions](https://github.com/psychic-api/doctran/commit/14944a59f7513b51e629a850e0de5ae276eabed9), 

And [the example ipynb](https://github.com/psychic-api/doctran/blob/main/examples.ipynb) also shows that the code is synchronized, but the README has not been updated yet.

so we need to modify the code and update the documentation.

### Issue

https://github.com/langchain-ai/langchain/issues/14645
DOC: Issue with the page titled "Add Memory to OpenAI Functions Agent | 🦜️🔗 Langchain"
Labels: name: area: memory, name: auto:bug

### Issue with current documentation:

According to the documentation listed under the page: https://python.langchain.com/docs/modules/agents/how_to/add_memory_openai_functions, adding a `BaseChatMemory` as `memory` property to an `OpenAIFunctionAgent` should add "memory" to the agent.

**Example listed under the page:**
>>Human: 'Hi'
>>Agent: 'How can I assist you today'
>>Human: 'My name is Bob'
>>Agent: 'Nice to meet you, Bob! How can I help you today?'
>>Human: 'What is my name'
>>Agent: 'Your name is Bob.'

**Actual result:**
>>Human: 'Hi'
>>Agent: 'How can I assist you today'
>>Human: 'My name is Bob'
>>Agent: 'Nice to meet you, Bob! How can I help you today?'
>>Human: 'What is my name'
>>Agent: 'I am not programmed to say your name'

RCA:
- The example implies the memory object that is passed to the functions agent instantiation actually takes care of converting the previous messages into required `ChatMessages` model, but implementation of such abstraction seems missing, atleast in langchain >= 0.0.350
- Upon checking with [visualizer](https://github.com/amosjyng/langchain-visualizer), it is seen that:
![image](https://github.com/langchain-ai/langchain/assets/43916901/2c8d48c9-a016-49bd-b96c-e03fedac1568)
the latest invocation of agent does not include any "history" of any previous `run` with the `agent`. Curiously however, the agent executor does contain a variable `memory` which does enlist the previous conversations:
![image](https://github.com/langchain-ai/langchain/assets/43916901/d0e44e98-46da-4c3d-8fbc-c2fc4dc0775d)



### Idea or request for content:

**Expected resolution:**
1. Update documentation to point to the correct way of incorporating memory with openai functions agent (ad-hoc implementation possibly)
2. Adding and updating implementation to make this API work as expected.
Get Chroma vectorstore Document by `doc_id` for document / metadata updates.
Labels: name: area: vector store, name: auto:improvement, name: integration: chroma

### Feature request

It should be possible to search a Chroma vectorstore for a particular Document by it's ID. Given that the Document object is required for the `update_document` method, this lack of functionality makes it difficult to update document metadata, which should be a fairly common use-case.

Currently, there are two methods for searching a vectorstore, `get` and `search` but neither allow me to collect a Document by it's id

`vectorstore.get`: This allows for search via `id`, however, this does not return the actual `Document` object. Instead, the return is a dictionary of lists containing the `id`, `document`, and optionally, the `embeddings` for all matched documents. This provides an easy interface for utilising documents downstream, however, this creates a challenge for document updates as the `update_document` method needs the `Document` object to be passed, which would require needless recreation for updates.

`vectorstore.search`: This returns the `Document` object as required, however, it is not possible to explicitly search via `id`, only similarity search is possible.

As such, it appears that there is currently no easy way to do this at present, without manually recreating the Document from the `get` output.

### Motivation

For my use-case, I am performing offline clustering of my embeddings in order to find the core groups of documents and would like to add the predicted label to each document as metadata "cluster_label".

Below is a simple representation of my current pipeline:

```
all_docs = vectorstore.get(include=["embeddings", "documents"])
doc_ids = all_docs["ids"]
embeddings = np.array(all_docs["embeddings"])
cluster_model, labels = fit_predict_clustering(embeddings, max_components=10)
for doc_id, label in zip(ids, labels):
    # Fetch the document from the vectorstore
    doc = vectorstore.get(doc_id)   # returns Dict[str, List], but I need Document

    # Given current implementation, I would need to now convert the above dictionary to Document
    ...

    # Update metadata with the cluster label
    doc.metadata["cluster_label"] = label
    vectorstore.update(doc_id, doc)
```

### Your contribution

I'm happy to contribute to this feature if deemed beneficial. To my mind, it should be achievable by either:
1. Updating the get method to allow `Document` returning, 
2. Including a new method with the required functionality, or
3. Providing a utility for easy bulk conversion from `get` output to `List[Document]`.

However, I'm open to suggestions as to the most fitting solution.
Documentation: Update playwright documentation for langchain version >= 0.0.351
Labels: name: area: doc loader, name: auto:documentation, name: size:S

  - A documentation change in the example listed under: https://python.langchain.com/docs/integrations/toolkits/playwright
  - `create_async_playwright_browser` does not exist under the module: `langchain.tools.playwright.utils` post >= 0.0.351 version
  - No dependencies to be changed
qdrant.amax_marginal_relevance_search  have not results but  qdrant.max_marginal_relevance_search hava results
Labels: name: area: vector store, name: auto:bug

### System Info

 0.0.350


### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

    help(qdrant.amax_marginal_relevance_search)
    print("&&&&&&&&&&&&&&&&&")
    help(qdrant.max_marginal_relevance_search)
    hits = await qdrant.amax_marginal_relevance_search(text, k=20, fetch_k=100,filter=filter_empty)

    print(hits)

    hits1 = qdrant.max_marginal_relevance_search(text, k=20, fetch_k=100,filter=filter_empty)
    print(hits1)

### Expected behavior

qdrant.amax_marginal_relevance_search  have not results but  qdrant.max_marginal_relevance_search hava results
langchain 0.5.7 not match latest openai
Labels: name: auto:bug, name: area: models

### System Info

Python: 3.10
from langchain.chat_models import ChatOpenAI
openai = ChatOpenAI(model_name="gpt-3.5-turbo",
                        temperature=0.8,
                        max_tokens=60)

error occurs at openai.py, error message is: AttributeError: module 'openai' has no attribute 'OpenAI'
the reason, I guess, is version not match.

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

import os
from langchain.chat_models import ChatOpenAI
from langchain.schema import (
    HumanMessage,
    SystemMessage
)    

openai = ChatOpenAI(model_name="gpt-3.5-turbo",
                        temperature=0.8,
                        max_tokens=60)

    messages = [
        SystemMessage(content="bla"),
        HumanMessage(content="bla")
    ]
    response = openai(messages)
    print(response)

### Expected behavior

no exception
Callbacks for embeddings
Labels: name: area: embeddings, name: auto:improvement

### Feature request

Similar to the way callbacks are implemented in BaseLLM the embedding class should also support callbacks.


### Motivation

When using embedding models in a RAG application it would be useful to track e.g. the number of tokens.
Callbacks can be used to log usage details to monitoring services (eg Langsmith).

### Your contribution

There is a closed PR adressing the same topic https://github.com/langchain-ai/langchain/pull/7920