delayedkarma/langchain-issues huggingface dataset:
Fix ChromaDB integration -> docker container instructions
Labels: name: area: vector store, name: auto:documentation

## Description
This PR handles modifying the Chroma DB integration's documentation.
It modifies the **Docker container** example to fix the instructions mentioned in the documentation.
In the current documentation, the below `client.reset()` line causes a runtime error:

```py
...
client = chromadb.HttpClient(settings=Settings(allow_reset=True))
client.reset()  # resets the database
collection = client.create_collection("my_collection")
...
```

`Exception: {"error":"ValueError('Resetting is not allowed by this configuration')"}`

This is due to the Chroma DB server needing to have the `allow_reset` flag set to `true` there as well.
This is fixed by adding the `ALLOW_RESET=TRUE` to the `docker-compose` file environment variable to the docker container before spinning it

## Issue
This fixes the runtime error that occurs when running the docker container example code

## Tag Maintainer
@rlancemartin, @eyurtsev
Huggingface_Pipeline for summarization returning generalized response
Labels: name: area: memory, name: auto:bug

### System Info

Python = 3.9
Langchain = 0.0.245





### Who can help?

@hwchase17 

### 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
- [X] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

I checked the recent update for summarization pipeline with memory as:
```
from langchain.llms import HuggingFacePipeline
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, pipeline
from langchain.memory import ConversationSummaryBufferMemory
import torch

summarize_model = AutoModelForSeq2SeqLM.from_pretrained("facebook/bart-large-cnn", device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
summarize_tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn", padding_side="left")
pipe_summary = pipeline("summarization", model=summarize_model, tokenizer=summarize_tokenizer) #, max_new_tokens=500, min_new_tokens=300

hf_summary = HuggingFacePipeline(pipeline=pipe_summary)
memory=ConversationSummaryBufferMemory(llm=hf_summary, max_token_limit=10)
```
Then, added chat history to the memory and observed the memory afterwards as:
```
memory.save_context({"input": "hi"}, {"output": "whats up"})
memory.save_context({"input": "not much you"}, {"output": "not much"})
memory.save_context({"input": "what's my name"}, {"output": "AJ"})

memory.load_memory_variables({})
```
It returned:
```
{'history': "System: The human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good because it will help humans reach their full potential. Progressively summarize the lines of conversation provided, adding onto the previous summary returning a new summary. The human asks the AI: Why do you think artificial Intelligence is a Force for good? The AI: Because artificial intelligence will help human reach their potential.\nHuman: what's my name\nAI: AJ"}
```
This doesn't summarize the actual chat history, but returns a generalized text: `The human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good because it will help humans reach their full potential. Progressively summarize the lines of conversation provided, adding onto the previous summary returning a new summary. The human asks the AI: Why do you think artificial Intelligence is a Force for good? The AI: Because artificial intelligence will help human reach their potential.`


### Expected behavior

This would pass wrong prompt to the LLM for question-answering. The expectation is the summary of the chat history.
DOC: Contributor docs are inaccurate
Labels: name: auto:documentation

### Issue with current documentation:

## Description
The installation instructions in the Contributor docs are not working and should be updated. For example:

```bash
> poetry install -E all
Installing dependencies from lock file

Extra [all] is not specified.
```

```bash
> poetry install --with dev

Group(s) not found: dev (via --with)
```


### Idea or request for content:

_No response_
Add support for Anyscale Endpoint, with llama2 70B model for now
Labels: name: auto:enhancement

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: a description of the change, 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: any dependencies required for this change,
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Adding support or Anyscale Endpoint, with default llama2 70B model for now
Issue: Azure/OpenAI get_num_tokens_from_messages returns wrong prompt tokens
Labels: name: auto:bug, name: auto:improvement

### Issue you'd like to raise.

OpenAI Cookbook

- https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb
  - `gpt-3.5-turbo-0301` set `tokens_per_message = 4` and `tokens_per_name = -1`
  - `gpt-3.5-turbo-*` set `tokens_per_message = 3` and `tokens_per_name = 1`
  - `gpt-3.5-turbo` redirect to `gpt-3.5-turbo-0613`
  - `gpt-4` redirect to `gpt-4-0613`

```
    if model in {
        "gpt-3.5-turbo-0613",
        "gpt-3.5-turbo-16k-0613",
        "gpt-4-0314",
        "gpt-4-32k-0314",
        "gpt-4-0613",
        "gpt-4-32k-0613",
        }:
        tokens_per_message = 3
        tokens_per_name = 1
    elif model == "gpt-3.5-turbo-0301":
        tokens_per_message = 4  # every message follows 
{role/name}\n{content}
\n
        tokens_per_name = -1  # if there's a name, the role is omitted
    elif "gpt-3.5-turbo" in model:
        print("Warning: gpt-3.5-turbo may update over time. Returning num tokens assuming gpt-3.5-turbo-0613.")
        return num_tokens_from_messages(messages, model="gpt-3.5-turbo-0613")
    elif "gpt-4" in model:
        print("Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613.")
        return num_tokens_from_messages(messages, model="gpt-4-0613")
```

LangChain

- https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/chat_models/openai.py#L541-L548
  - `gpt-3.5-turbo` and `gpt-3.5-turbo-*` set `tokens_per_message = 4` and `tokens_per_name = -1`

```
        if model.startswith("gpt-3.5-turbo"):
            # every message follows <im_start>{role/name}\n{content}<im_end>\n
            tokens_per_message = 4
            # if there's a name, the role is omitted
            tokens_per_name = -1
        elif model.startswith("gpt-4"):
            tokens_per_message = 3
            tokens_per_name = 1
```

- https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/chat_models/openai.py#L508-L515
  - `gpt-3.5-turbo` redirect to `gpt-3.5-turbo-0301`
  - `gpt-4` redirect to `gpt-4-0314`

```
            if model == "gpt-3.5-turbo":
                # gpt-3.5-turbo may change over time.
                # Returning num tokens assuming gpt-3.5-turbo-0301.
                model = "gpt-3.5-turbo-0301"
            elif model == "gpt-4":
                # gpt-4 may change over time.
                # Returning num tokens assuming gpt-4-0314.
                model = "gpt-4-0314"
```

### Suggestion:

Follow the OpenAI Cookbook
- `gpt-3.5-turbo-0301` set `tokens_per_message = 4` and `tokens_per_name = -1`
- `gpt-3.5-turbo-*` set `tokens_per_message = 3` and `tokens_per_name = 1`
PromptTemplate update documentation and expand kwarg
Labels: name: auto:documentation

# PromptTemplate

* Update documentation to highlight the classmethod for instantiating a prompt template.
* Expand kwargs in the classmethod to make parameters easier to discover

This PR got reverted here: https://github.com/langchain-ai/langchain/pull/8395/files

Unit tests got coupled due to slight change in serialization of prompt templates.

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: a description of the change, 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: any dependencies required for this change,
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Add RoPE Scaling params from llamacpp
Labels: name: lgtm, name: auto:improvement

Description:
Just adding parameters from `llama-python-cpp` that support RoPE scaling.
@hwchase17, @baskaryan

sources:
papers and explanation:
https://kaiokendev.github.io/context
llamacpp conversation:
https://github.com/ggerganov/llama.cpp/discussions/1965 
Supports models like:
https://huggingface.co/conceptofmind/LLongMA-2-13b


img from
https://llama-cpp-python.readthedocs.io/en/latest/api-reference/#llama_cpp.Llama
![Screen Shot 2023-07-28 at 11 27 26 AM](https://github.com/langchain-ai/langchain/assets/64715088/c704da96-d8ac-4a4a-b32a-6ee796f1201b)

- [x] lint and format
Question: How can I include SystemMessage with RetrievalQA
Labels: name: area: agent, name: auto:question

I'd like to incorporate this 'system_message' with each whenever I call 'qa.run(prompt)'.
How is this possible. Can someone help?

Here is the code I wrote to initialize the LLM and the RetrievalQA:

```from langchain.chat_models import ChatOpenAI
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
from langchain.prompts import ChatPromptTemplate
from langchain.chains import RetrievalQA, LLMChain
from langchain.schema import (
    AIMessage,
    HumanMessage,
    SystemMessage
)

llm = ChatOpenAI(
    openai_api_key=OPENAI_API_KEY,
    model_name = 'gpt-3.5-turbo',
    temperature=0.0
)

system_message = [SystemMessage(
    content='You are a Virtual Vet. '
    'You should help clients with their concerns about their pets and provide helpful solutions.'
    'You can ask questions to help you understand and diagnose the problem.'
    'You should only talk within the context of problem.'
    'If you are unsure of how to help, you can suggest the client to go to the nearest clink of their place.'
    'You should talk on German, unless the client talks in English.')]


conversational_memory = ConversationBufferWindowMemory(
    memory_key='chat_history',
    k=2,
    return_messages=True
)

qa = RetrievalQA.from_chain_type(
    llm=llm,
    chain_type='stuff',
    retriever=vectorstore.as_retriever(),
)
GPTCache object should be created during or before the first lookup
Labels: name: area: memory, name: auto:bug

### System Info

langchain==0.0.245
gptcache==0.1.37

### Who can help?

_No response_

### Information

- [X] 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

```python
from gptcache import Cache
from gptcache.adapter.api import init_similar_cache
from langchain.cache import GPTCache

# In the first llm predict call the cache is not initialized and always returns None

def init_gptcache(cache_obj: Cache, llm_str: str):
    init_similar_cache(cache_obj=cache_obj, data_dir=f"similar_cache_{llm_str}")

langchain.llm_cache = GPTCache(init_gptcache)
llm = OpenAI(model_name="text-davinci-002", temperature=0.2)
llm.predict("tell me a joke")
```

### Expected behavior

It should first create the gptcache object and check the cache. This becomes a problem if I use external dbs for gptcache for my langchain app.

Please assign this issue to me. I am willing to contribute on this one.
Devcontainer README -> Clarification.
Labels: name: auto:documentation

  - Description: The contribution guidlelines using devcontainer refer to the main repo and not the forked repo.  We should create our changes in our own forked repo, not on langchain/main
  - Issue: Just documentation
  - Dependencies: N/A,
  - Tag maintainer: @baskaryan
  - Twitter handle: @levalencia


If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Issue: LangChain is fairly consistently dropping the first one or two characters of the chain answer.
Labels: name: area: embeddings, name: auto:bug

### Issue you'd like to raise.

My Chatbot is fairly straight forward. It uses MosaicMLInstructorEmbeddings() as the embedding and MosaicML() as the model. I have a file that I want to retrieve from. When outputting an answer, for instance:

What is AliBi?

It will give a response like:

Answer: LiBi (Attention with Linear Biases) dispenses with position embeddings for tokens in transformer-based NLP models, instead encoding position information by biasing the query-key attention scores proportionally to each token pair’s distance. ALiBi yields excellent extrapolation to unseen sequence lengths compared to other position embedding schemes. We leverage this extrapolation capability by training with shorter sequence lengths, which reduces the memory and computation load. 

Or when I give it:

Answer: arded checkpointing is a feature in distributed systems that allows for the checkpointing of the state of the system to be divided into multiple shards. This is useful for systems that have a large amount of data or compute to perform. 

I have noticed that the chatbot fairly consistently drops the first or first two characters and I'm wondering if this is a bug with LangChain, MosaicMLInstructorEmbeddings, or MosaicML.

Here is my chatbot file:
https://github.com/KuuCi/examples/blob/support-bot/examples/end-to-end-examples/support_chatbot/chatbot.py

### Suggestion:

_No response_
Fix GitLoader to handle repeated load calls
Labels: name: area: doc loader, name: auto:improvement

**Description: a description of the change**

In this pull request, GitLoader has been updated to handle multiple load calls, provided the same repository is being cloned. Previously, calling `load` multiple times would raise an error if a clone URL was provided.

Additionally, a check has been added to raise a ValueError when attempting to clone a different repository into an existing path.

New tests have also been introduced to verify the correct behavior of the GitLoader class when `load` is called multiple times.

Lastly, the GitPython package, a dependency for the GitLoader class, has been added to the project dependencies (pyproject.toml and poetry.lock).

**Issue: the issue # it fixes (if applicable)**

None

**Dependencies: any dependencies required for this change**

GitPython

**Tag maintainer: for a quicker response, tag the relevant maintainer (see below)**

- DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
added top_k and use_mmr to add_texts
Labels: name: area: vector store, name: auto:improvement

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: a description of the change, 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: any dependencies required for this change,
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
doc(prompts): Add redirect to fix broken link on Prompts Page
Labels: name: lgtm, name: auto:documentation

<!-- Thank you for contributing to LangChain!

Replace this comment with: -->
  - Description: Fixes a broken link in https://docs.langchain.com/docs/components/prompts/ with a redirect
  - Issue: #8105
  - Dependencies: none
  - Tag maintainer: @baskaryan
  - Twitter handle: [@BharatR123](https://twitter.com/BharatR123)

<!--
Please make sure you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->
Issue: prefix `Use ` being added to agent action causing InvalidTool to be invoked again and again
Labels: name: area: agent, name: auto:bug

### Issue you'd like to raise.

I have added the tools named A_tool, default_tool  to a `ZeroShotAgent`.

The output from one of the execution looks like:

```
Thought: We need to use the A_tool.
Action: Use A_tool
Observation: Use A_tool is not a valid tool, try another one.
Thought:We need to use the default_tool since A_tool is not a valid tool.
    
Action: Use default_tool
Action Input: None
Observation: Use default_tool is not a valid tool, try another one.
```

I am not sure why the prefix `Use ` is getting added to Action.....ideally action should be just the name of the tool [`A_tool`,` default_tool`]

This is causing InvalidTool to be invoked again and again.

What can i do to fix this issue?

### Suggestion:

_No response_
Add more CodeSegmenters
Labels: name: auto:enhancement

### Feature request

I'm interested in the code segmenters created. So far we have python and javascript. I'm looking for a typescript one in particular, the JS one marks my typescript as invalid. But in general, having the language support shown in the text splitter Language enum would be ideal but with full on parsing. 

### Motivation

This call is ok to start: 
`RecursiveCharacterTextSplitter.get_separators_for_language(Language.JS)`
but when we're splitting by the word function we're cutting off `export async` or `default`, and especially JsDoc, which is probably the best think to start a chunk of a function with. 

Splitting by keywords like this is kinda clunky as a long term solution because of the above cases and others, having something that's more carefully splitting files up would be better. 

### Your contribution

Maybe instead of a parser like eprisma, there's just a generic one that's powered by an LLM.
add: license file to subproject
Labels: name: lgtm, name: auto:nit

<!-- Thank you for contributing to LangChain!

Replace this comment with:
  - Description: a description of the change, 
  - Issue: the issue # it fixes (if applicable),
  - Dependencies: any dependencies required for this change,
  - Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
  - 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 you're PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

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.

Maintainer responsibilities:
  - General / Misc / if you don't know who to tag: @baskaryan
  - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev
  - Models / Prompts: @hwchase17, @baskaryan
  - Memory: @hwchase17
  - Agents / Tools / Toolkits: @hinthornw
  - Tracing / Callbacks: @agola11
  - Async: @agola11

If no one reviews your PR within a few days, feel free to @-mention the same people again.

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
 -->

hi!
This is pretty straight-forward: The sdist package does not contain the license file (which is needed by e.g. conda) because the package is built from the subdir and can't see the license.
I _copied_ the license but since I'm unfamiliar with the projects direction, I'm not sure that's correct.
thanks!