Repository: Giskard-AI/giskard-oss
Issue: Configuring Knowledgebase class to use Gemini as LLM client but it still uses Open AI
Root cause: Configuration Error

### Issue Type

Bug

### Source

source

### Giskard Library Version

2.15.2

### OS Platform and Distribution

windows 11

### Python version

3.11

### Installed python packages

_No response_

### Current Behaviour?

```shell
A bug happened!
I'm using rag test set generation using Gemini client.
When I intialize the knowledgebase using the data frame and llm client
I got an error:
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

Although I defined my llm client to be used instead of using OPENAI by default
```


### Standalone code OR list down the steps to reproduce the issue

```shell
import os
import giskard
import pandas as pd
import google.generativeai as genai
from giskard.llm.client.gemini import GeminiClient
from llama_index.core.node_parser import SentenceSplitter
from llama_index.readers.file import PyMuPDFReader
from giskard.rag import KnowledgeBase, generate_testset, QATestset

pd.set_option("display.max_colwidth", 400)
os.environ["API_KEY"] = "AIzxxxxxxxx..."
genai.configure(api_key=os.environ["API_KEY"])
oc = GeminiClient()
giskard.llm.set_default_client(oc)
print("Client successfully set.")

# Load your data and initialize the KnowledgeBase
loader = PyMuPDFReader()
CVs_documents = loader.load(file_path="../KnowledgeBase/Walaa Akram Anwar.pdf")
print("pdf content is ", CVs_documents)
splitter = SentenceSplitter(chunk_size=512)
text_nodes = splitter(CVs_documents)
knowledge_base_df = pd.DataFrame([node.text for node in text_nodes], columns=["text"])
knowledge_base = KnowledgeBase(knowledge_base_df, llm_client=GeminiClient())
testSet = generate_testset(knowledge_base,
                           num_questons=6,
                           agent_description="A chatbot answering questions about CVS")
print("generated Questions ", testSet)
testSet = QATestset.load("CVs_testset.jsonl")
testSet.to_pandas().head(5)
```


### Relevant log output

_No response_

Hi @walaa-akram,
thanks for reporting this bug.

By default, `giskard` library will try to usen OpenAI embedding model, but you can set another one as default. For example, you can use FastEmbed executing the following code before loading data and initializing the KB:

```
from giskard.llm.embeddings.fastembed import try_get_fastembed_embeddings

fe = try_get_fastembed_embeddings()
giskard.llm.embeddings.set_default_embedding(fe)
```

And update the KnowledgeBase instantiation (if you want to use the same Embedding model):

```
knowledge_base = KnowledgeBase(knowledge_base_df, llm_client=GeminiClient(), embedding_model=fe)
```

For more info regarding the custom embedding models, please check the `Custom Client` tab of the docs here: https://docs.giskard.ai/en/latest/open_source/testset_generation/testset_generation/index.html#before-starting

Hello @henchaves 
I read the document and pplied your recommendation but still get an error.
Do you have any other recommendations?
`import os
import giskard
import pandas as pd
import google.generativeai as genai
from giskard.llm.client.gemini import GeminiClient
from giskard.llm.embeddings.fastembed import try_get_fastembed_embeddings
from llama_index.core.node_parser import SentenceSplitter
from llama_index.readers.file import PyMuPDFReader
from giskard.rag import KnowledgeBase, generate_testset, QATestset

pd.set_option("display.max_colwidth", 400)
os.environ["API_KEY"] = "AIzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
genai.configure(api_key=os.environ["API_KEY"])
fe = try_get_fastembed_embeddings()
giskard.llm.embeddings.set_default_embedding(fe)
oc = GeminiClient(model="gemini-pro")
giskard.llm.set_default_client(oc)
print("Client successfully set.")

loader = PyMuPDFReader()
CVs_documents = loader.load(file_path="../KnowledgeBase/Walaa Akram Anwar.pdf")
print("pdf content is ", CVs_documents)
splitter = SentenceSplitter(chunk_size=512)
text_nodes = splitter(CVs_documents)
knowledge_base_df = pd.DataFrame([node.text for node in text_nodes], columns=["text"])
knowledge_base = KnowledgeBase(data=knowledge_base_df, llm_client=oc, embedding_model=fe)
testSet = generate_testset(knowledge_base, num_questions=6, agent_description="A chatbot answering questions about CVS")
print("generated Questions ", testSet)
QATestset.save(testSet,path="CVs_testSet.jsonl")
testSet.to_pandas().head(5)`

the error appears is:
:\OracleAutomation\AIAutomation\RAGTesting\TestDataGenerationUsingGemini.py", line 26, in <module>
    knowledge_base = KnowledgeBase(data=knowledge_base_df, llm_client=oc, embedding_model=fe)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Walaa Akram\AppData\Local\Programs\Python\Python311\Lib\site-packages\giskard\rag\knowledge_base.py", line 139, in __init__
    self._embedding_model = embedding_model or get_default_embedding()
                                               ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Walaa Akram\AppData\Local\Programs\Python\Python311\Lib\site-packages\giskard\llm\embeddings\__init__.py", line 19, in get_default_embedding
    _default_embedding = _default_embedding or try_get_openai_embeddings() or try_get_fastembed_embeddings()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Walaa Akram\AppData\Local\Programs\Python\Python311\Lib\site-packages\giskard\llm\embeddings\openai.py", line 68, in try_get_openai_embeddings
    client = OpenAI()
             ^^^^^^^^
  File "C:\Users\Walaa Akram\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\_client.py", line 105, in __init__
    raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

Process finished with exit code 1