Unable to Apply frequencyPenalty Parameter to ChatOpenAI Class
Labels: name: area: embeddings, name: auto:bug, name: auto:documentation

### System Info

Issue:

I'm experiencing an issue while trying to apply the `frequencyPenalty` parameter to the `ChatOpenAI` class in my Flask server setup. I'm running a Flask server that handles a POST query and returns a streaming response from GPT using LlamaIndex.

When I attempt to apply the `frequencyPenalty` parameter to `ChatOpenAI` instance, the server throws a warning:

```python
WARNING! frequencyPenalty is not default parameter.
frequencyPenalty was transferred to model_kwargs.
Please confirm that frequencyPenalty is what you intended.
```

Upon reviewing the documentation, I didn't find a clear way to apply the `frequencyPenalty` to the `ChatOpenAI` class. 

Here's a snippet of my current code where I'm experiencing this issue:

```python
# LLM that supports streaming
llm = ChatOpenAI(model_name="gpt-3.5-turbo-16k", streaming=True, frequencyPenalty=6)
llm_predictor = LLMPredictor(llm=llm)
```

I'm using `ChatOpenAI` to create an instance of the LLM that supports streaming. I intended to apply `frequencyPenalty` to this instance but encountered the above warning.

For further reference, the complete code of my Flask server setup is shared in the original post.

Any guidance on how to correctly apply the `frequencyPenalty` to `ChatOpenAI` would be greatly appreciated. Thanks in advance!

### Who can help?

_No response_

### 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
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```
import openai
from flask import Flask, request, Response
from flask_cors import CORS
from dotenv import load_dotenv
import os
import pandas as pd
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader, ServiceContext, LLMPredictor, Document
from langchain.chat_models import ChatOpenAI
import logging

app = Flask(__name__)
CORS(app)

load_dotenv()

# Get the API key from the environment variable
api_key = os.getenv('OPENAI_API_KEY')

# Set the OpenAI API key directly
openai.api_key = api_key

# Loading documents from an Excel file
df = pd.read_excel('data/SupplierComplete.xlsx')

# Convert DataFrame rows into documents
documents = [
    Document(text=' '.join(f'{name}: {value}' for name, value in zip(df.columns, map(str, row.values))))
    for _, row in df.iterrows()
]

# LLM that supports streaming
llm = ChatOpenAI(model_name="gpt-3.5-turbo-16k", streaming=True, frequencyPenalty=6)
llm_predictor = LLMPredictor(llm=llm)

# Construct a simple vector index
index = GPTVectorStoreIndex.from_documents(documents, service_context=ServiceContext.from_defaults(llm_predictor=llm_predictor))

# Configure query engine to use streaming
query_engine = index.as_query_engine(streaming=True, similarity_top_k=2)

@app.route('/api/query', methods=['POST'])
def query():
    try:
        # Get the payload from the request
        payload = request.json

        # Log the received payload
        logging.info(f"Received payload: {payload}")

        # Update the LLMPredictor parameters based on the payload
        llm_predictor.max_tokens = payload.get('max_tokens', 256)
        llm_predictor.llm.temperature = payload.get('temperature', 0.9)

        # Get the system message from the payload
        system_message = [m['content'] for m in payload['messages'] if m['role'] == 'system'][0]

        # Get the question from the messages in the payload
        user_message = [m['content'] for m in payload['messages'] if m['role'] == 'user'][-1]

        # Combine system message and user message
        question = system_message + ' ' + user_message

        # Now, query returns a StreamingResponse object
        streaming_response = query_engine.query(question)

        def response_stream():
            for text in streaming_response.response_gen:
                yield text + "\n"

        return Response(response_stream(), mimetype="text/event-stream")

    except Exception as e:
        logging.error(f"Exception occurred: {e}")
        return Response(f"Server error: {e}", status=500)

if __name__ == '__main__':
    # Start the server, to run this script use "python llama_index_server.py" in terminal

    # Configure logging level
    logging.basicConfig(level=logging.DEBUG)

    app.run(host='0.0.0.0', port=5000, debug=True)
```

### Expected behavior

I expect to be able to apply the frequencyPenalty parameter to the ChatOpenAI class without encountering any warning messages or errors. Ideally, the frequencyPenalty should influence the LLM's generation by tuning the model's likelihood to avoid frequently occurring responses. I'm expecting this to work seamlessly with other parameters and configurations I'm setting up for my ChatOpenAI instance.

If there is a specific way or an alternate parameter to achieve this functionality, I would expect the documentation to clearly illustrate this. Also, any warnings or error messages should provide actionable insights or steps for resolution.