AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Add llm eval (#197)
merwanehamadi01b118e590f0
diff --git a/.env.example b/.env.exampleindex 66764df683..eaeaaff3ee 100644--- a/.env.example+++ b/.env.example@@ -1,3 +1,4 @@AGENT_NAME=mini-agiREPORT_LOCATION="../../reports/mini-agi"-MOCK_TEST=False\ No newline at end of file+MOCK_TEST=False+OPENAI_API_KEY="sk-"diff --git a/.gitmodules b/.gitmodulesindex 54313e1995..0e8d6ea14d 100644--- a/.gitmodules+++ b/.gitmodules@@ -26,6 +26,7 @@path = agent/beeboturl = https://github.com/merwanehamadi/beebot.gitbranch = master-[submodule "agbenchmark/challenges"]+[submodule "agbenchmark/challenges"]path = agbenchmark/challengesurl = https://github.com/SilenNaihin/agbenchmark_challenges.git+ branch = maindiff --git a/agbenchmark/challenges b/agbenchmark/challengesindex 59d44a6f4f..8153f05f75 160000--- a/agbenchmark/challenges+++ b/agbenchmark/challenges@@ -1 +1 @@-Subproject commit 59d44a6f4f3cd778d9034857f7277428269b2028+Subproject commit 8153f05f758d86ddf01fe7d8cb4fb7c53ddc4d72diff --git a/agbenchmark/utils/challenge.py b/agbenchmark/utils/challenge.pyindex 02141b4eb8..5a8e1273e9 100644--- a/agbenchmark/utils/challenge.py+++ b/agbenchmark/utils/challenge.py@@ -5,6 +5,9 @@ import sysfrom abc import ABCfrom typing import Any, Dict, List+import openai++from agbenchmark.agent_interface import MOCK_FLAGfrom agbenchmark.utils.data_types import ChallengeData, Ground@@ -117,7 +120,9 @@ class Challenge(ABC):print_content = (f"\033[1;34mWord that should exist\033[0m - {should_contain_word}:")- if should_contain_word not in content:+ if self.data.ground.type == "file_llm_evaluation":+ return self.llm_eval(content, should_contain_word)+ elif should_contain_word not in content:print(print_content, "False")return 0.0else:@@ -134,6 +139,26 @@ class Challenge(ABC):return 1.0+ def llm_eval(self, content: str, should_contain_word: str) -> float:+ openai.api_key = os.getenv("OPENAI_API_KEY")+ if MOCK_FLAG:+ return 1.0+ evaluation_question = f"""+QUESTION:+{should_contain_word} Answer with 0 for no, 1 for yes.+CONTENT:+{content}+ANSWER:++"""+ answer = openai.ChatCompletion.create(+ model="gpt-4",+ messages=[+ {"role": "system", "content": evaluation_question},+ ],+ )+ return float(answer["choices"][0]["message"]["content"])+def get_scores(self, config: Dict[str, Any]) -> dict[str, Any]:scores = []scores_dict = {}