mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
(docs) cook book autoevals
This commit is contained in:
parent
3280a8e2e2
commit
b92f4c8d3c
1 changed files with 35 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
||||||
|
import sys, os
|
||||||
|
import traceback
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
import litellm
|
||||||
|
from litellm import embedding, completion, completion_cost
|
||||||
|
|
||||||
|
from autoevals.llm import *
|
||||||
|
###################
|
||||||
|
import litellm
|
||||||
|
|
||||||
|
# litellm completion call
|
||||||
|
question = "which country has the highest population"
|
||||||
|
response = litellm.completion(
|
||||||
|
model = "gpt-3.5-turbo",
|
||||||
|
messages = [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": question
|
||||||
|
}
|
||||||
|
],
|
||||||
|
)
|
||||||
|
print(response)
|
||||||
|
# use the auto eval Factuality() evaluator
|
||||||
|
|
||||||
|
print("calling evaluator")
|
||||||
|
evaluator = Factuality()
|
||||||
|
result = evaluator(
|
||||||
|
output=response.choices[0]["message"]["content"], # response from litellm.completion()
|
||||||
|
expected="India", # expected output
|
||||||
|
input=question # question passed to litellm.completion
|
||||||
|
)
|
||||||
|
|
||||||
|
print(result)
|
Loading…
Add table
Add a link
Reference in a new issue