Repository: truera/trulens
Issue: [BUG] v0.20.3 of trulens-eval AzureOpenAI  object has no attribute 'generate_score'
Root cause: Unimplemented Feature Gap

**Bug Description**
What happened? I am trying to create a custom AzureOpenAI Model which defines a custom function with a system prompt. I would like to use AzureOpenAI LLM to generate a score between two sentences.

**To Reproduce**

```python
from trulens_eval.feedback.provider import AzureOpenAI
class CustomAzureOpenAI(AzureOpenAI):
    def semantic_similarity_between_two_sentences(self, sentence_1: str, sentence_2: str) -> float:
        """
        Custom feedback function to score, extending OpenAI provider.

        Args:
            response (str):

        Returns:
            float: 
        """
        system_prompt: str = """
        Compare the semantic similarity between the following two sentences. Sentence one is '{one}', while sentence two is '{two}'.
        
        Answer only with an integer 0 and 1 based on how semantically similar the sentences are. 
        where 0 is no semantic similarity at all and 1 is perfect agreement between the two sentences.
        
        Never elaborate.
        """.format(one=sentence_1, two=sentence_2)
        return self.generate_score(system_prompt=system_prompt)

openai_provider = CustomAzureOpenAI(api_key=token, deployment_name="gpt-4-0613")
openai_provider.semantic_similarity_between_two_sentences(sentence_1="This is a simple sentence.", sentence_2="This is also a simple sentence.")
```



**Expected behavior**
Expect the last line to provide a numerical value similar to the documentation defined here. 

https://www.trulens.org/trulens_eval/evaluation/feedback_implementations/custom_feedback_functions/#extending-existing-providers

**Relevant Logs/Tracebacks**
Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. If the issue is related to the TruLens dashboard, please also include a screenshot.
```
AttributeError                            Traceback (most recent call last)
Cell In[32], line 1
----> 1 openai_provider.semantic_similarity_between_two_sentences(sentence_1="This is a simple sentence.", sentence_2="This is also a simple sentence.")

Cell In[30], line 21, in CustomAzureOpenAI.semantic_similarity_between_two_sentences(self, sentence_1, sentence_2)
      4 """
      5 Custom feedback function to score, extending OpenAI provider.
      6 
   (...)
     11     float: 
     12 """
     13 system_prompt: str = """
     14 Compare the semantic similarity between the following two sentences. Sentence one is '{one}', while sentence two is '{two}'.
     15 
   (...)
     19 Never elaborate.
     20 """.format(one=sentence_1, two=sentence_2)
---> 21 return self.generate_score(system_prompt=system_prompt)

File [C:\JPMC\DEV\TMP\ds\projects\onboarding\appendix-x-search\.venv\Lib\site-packages\pydantic\main.py:811](file:///C:/JPMC/DEV/TMP/ds/projects/onboarding/appendix-x-search/.venv/Lib/site-packages/pydantic/main.py#line=810), in BaseModel.__getattr__(self, item)
    808     return super().__getattribute__(item)  # Raises AttributeError if appropriate
    809 else:
    810     # this is the current error
--> 811     raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')

AttributeError: 'CustomAzureOpenAI' object has no attribute 'generate_score'
```

**Environment:**
 - OS: [e.g. MacOS, Windows] - Windows
 - Python Version: 3.11.7 (tags/v3.11.7:fa7a6f2, Dec  4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)]
 - TruLens version: 0.20.3
 - Versions of other relevant installed libraries
OpenAI 1.30.3


**Additional context**
Add any other context about the problem here.

If the generate_score is not available in 0.20.3, what is the earliest version where it is available? I am unable to bring in 0.30.1 due to my company detecting a vulnerability with joblib. 

Please advise.

<!-- Greeting -->
Hey @jordan-carson! I'm here to help you with any bug fixes, questions, or contributions you might need. Let's squash those bugs together! 😊

<!-- Answer -->
The `generate_score` method is not available in TruLens version 0.20.3. It was introduced in version 0.24.0 <sup>[[1]](https://github.com/truera/trulens/blob/main/trulens_eval/trulens_eval/feedback/provider/base.py)</sup>.

As a workaround in version 0.20.3, you can use the `generate_score_and_reasons` method, which provides similar functionality by generating a score and optionally providing reason metadata. Here is an example of how you can modify your `CustomAzureOpenAI` class to use this method:

```python
from trulens_eval.feedback.provider import AzureOpenAI
class CustomAzureOpenAI(AzureOpenAI):
    def semantic_similarity_between_two_sentences(self, sentence_1: str, sentence_2: str) -> float:
        """
        Custom feedback function to score, extending OpenAI provider.

        Args:
            response (str):

        Returns:
            float: 
        """
        system_prompt: str = """
        Compare the semantic similarity between the following two sentences. Sentence one is '{one}', while sentence two is '{two}'.
        
        Answer only with an integer 0 and 1 based on how semantically similar the sentences are. 
        where 0 is no semantic similarity at all and 1 is perfect agreement between the two sentences.
        
        Never elaborate.
        """.format(one=sentence_1, two=sentence_2)
        score, _ = self.generate_score_and_reasons(system_prompt=system_prompt)
        return score

openai_provider = CustomAzureOpenAI(api_key=token, deployment_name="gpt-4-0613")
print(openai_provider.semantic_similarity_between_two_sentences(sentence_1="This is a simple sentence.", sentence_2="This is also a simple sentence."))
```

This should allow you to achieve the desired functionality without upgrading to a version that includes `generate_score` <sup>[[2]](https://github.com/truera/trulens/blob/main/trulens_eval/trulens_eval/feedback/provider/bedrock.py)</sup><sup>[[1]](https://github.com/truera/trulens/blob/main/trulens_eval/trulens_eval/feedback/provider/base.py)</sup>.


<!-- Dosu Comment Footer -->
<details open>
<summary>

#### Details
</summary>

**About Dosu**
This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
</details>

*To continue the conversation, mention @dosu.*


@dosu got this mostly right. If you want access to `generate_score` or `generate_score_and_reasons`, please upgrade.

`pip install -U trulens_eval`