|
4 | 4 | import ldclient |
5 | 5 | from ldclient import Context |
6 | 6 | from ldclient.config import Config |
7 | | -from ldai import LDAIClient, AICompletionConfigDefault |
| 7 | +from ldai import LDAIClient, AIJudgeConfigDefault |
8 | 8 |
|
9 | 9 | # Set sdk_key to your LaunchDarkly SDK key. |
10 | 10 | sdk_key = os.getenv('LAUNCHDARKLY_SDK_KEY') |
@@ -38,12 +38,21 @@ async def async_main(): |
38 | 38 | ) |
39 | 39 |
|
40 | 40 | try: |
41 | | - # Example of using the judge functionality with direct input and output |
42 | | - # Get AI judge configuration from LaunchDarkly |
43 | | - judge_default_value = AICompletionConfigDefault( |
44 | | - enabled=False, |
45 | | - ) |
46 | | - judge = await aiclient.create_judge(judge_key, context, judge_default_value) |
| 41 | + # Pass a default for improved resiliency when the AI config is unavailable |
| 42 | + # or LaunchDarkly is unreachable; omit for a disabled default. |
| 43 | + # Example (enabled default; judge default has three messages): |
| 44 | + # default = AIJudgeConfigDefault( |
| 45 | + # enabled=True, |
| 46 | + # model={'name': 'gpt-4'}, |
| 47 | + # provider={'name': 'openai'}, |
| 48 | + # messages=[ |
| 49 | + # {'role': 'system', 'content': 'Your judge criteria here.'}, |
| 50 | + # {'role': 'assistant', 'content': 'MESSAGE HISTORY: {{message_history}}'}, |
| 51 | + # {'role': 'user', 'content': 'RESPONSE TO EVALUATE: {{response_to_evaluate}}'}, |
| 52 | + # ], |
| 53 | + # ) |
| 54 | + # judge = await aiclient.create_judge(judge_key, context, default) |
| 55 | + judge = await aiclient.create_judge(judge_key, context) |
47 | 56 |
|
48 | 57 | if not judge: |
49 | 58 | print(f"*** AI judge configuration is not enabled for key: {judge_key}") |
|
0 commit comments