MetaGPT/test.ipynb
2024-07-01 16:56:47 +08:00

93 lines
3.3 KiB
Text

{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Usage\n",
"\n",
"human_eval_example = \"\"\"\n",
"from typing import List\\n\\n\\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\\n \\\"\\\"\\\" Check if in given list of numbers, are any two numbers closer to each other than\\n given threshold.\\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\\n False\\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\\n True\\n \\\"\\\"\\\"\\n\n",
"\"\"\"\n",
"\n",
"problem = \"\"\"\n",
"Human: Write a function that takes a list of numbers and returns the sum of the numbers at even indices.\n",
"\n",
"Function Signature:\n",
"def sum_even_indices(numbers: List[int]) -> int:\n",
"\n",
"Example:\n",
">>> sum_even_indices([1, 2, 3, 4, 5])\n",
"9 # 1 + 3 + 5 = 9\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'code': 'from typing import List\\n\\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\\n given threshold.\\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\\n False\\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\\n True\\n \"\"\"\\n numbers_sorted = sorted(numbers)\\n for i in range(len(numbers_sorted) - 1):\\n if abs(numbers_sorted[i] - numbers_sorted[i + 1]) < threshold:\\n return True\\n return False'}\n",
"{'result': True}\n"
]
},
{
"data": {
"text/plain": [
"{'code': 'from typing import List\\n\\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\\n given threshold.\\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\\n False\\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\\n True\\n \"\"\"\\n numbers_sorted = sorted(numbers)\\n for i in range(len(numbers_sorted) - 1):\\n if abs(numbers_sorted[i] - numbers_sorted[i + 1]) < threshold:\\n return True\\n return False'}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Test\n",
"\n",
"from examples.ags.demo.graph import HumanEvalGraph\n",
"solver = HumanEvalGraph(name=\"solver\", llm='gpt-4-turbo', criteria='correctness, efficiency, readability')\n",
"result = solver(human_eval_example)\n",
"result"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# TODO\n",
"# 1. 改成MG\n",
"# 2. 添加HumanEval"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}