API Reference¶
nearai ¶
EntryLocation ¶
Bases: BaseModel
EntryLocation
Source code in nearai/openapi_client/models/entry_location.py
from_dict classmethod
¶
Create an instance of EntryLocation from a dict
Source code in nearai/openapi_client/models/entry_location.py
from_json classmethod
¶
to_dict ¶
Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's self.model_dump(by_alias=True)
:
None
is only added to the output dict for nullable fields that were set at model initialization. Other fields with valueNone
are ignored.
Source code in nearai/openapi_client/models/entry_location.py
to_json ¶
Returns the JSON representation of the model using alias
parse_location ¶
parse_location(entry_location: str) -> EntryLocation
Create a EntryLocation from a string in the format namespace/name/version.
Source code in nearai/lib.py
agents ¶
agent ¶
Agent ¶
Bases: object
Source code in nearai/agents/agent.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
load_agent staticmethod
¶
load_agent(name: str, config: ClientConfig, local: bool = False)
Loads a single agent from the registry.
Source code in nearai/agents/agent.py
load_agents staticmethod
¶
load_agents(agents: str, config: ClientConfig, local: bool = False)
set_agent_metadata ¶
Set agent details from metadata.
Source code in nearai/agents/agent.py
write_agent_files_to_temp staticmethod
¶
Write agent files to a temporary directory.
Source code in nearai/agents/agent.py
environment ¶
Environment ¶
Bases: object
Source code in nearai/agents/environment.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
|
_list_messages ¶
_list_messages(limit: Union[int, NotGiven] = NOT_GIVEN, order: Literal['asc', 'desc'] = 'asc', thread_id: Optional[str] = None) -> List[Message]
Returns messages from the environment.
Source code in nearai/agents/environment.py
_run_inference_completions ¶
_run_inference_completions(messages: Union[Iterable[ChatCompletionMessageParam], str], model: Union[Iterable[ChatCompletionMessageParam], str], stream: bool, **kwargs: Any) -> Union[ModelResponse, CustomStreamWrapper]
Run inference completions for given parameters.
Source code in nearai/agents/environment.py
add_agent_log ¶
Add agent log with timestamp and log level.
Source code in nearai/agents/environment.py
add_agent_start_system_log ¶
Adds agent start system log.
Source code in nearai/agents/environment.py
add_file_to_vector_store ¶
add_message ¶
add_message(role: str, message: str, attachments: Optional[Iterable[Attachment]] = None, **kwargs: Any)
Deprecated. Please use add_reply
instead. Assistant adds a message to the environment.
Source code in nearai/agents/environment.py
add_reply ¶
add_reply(message: str, attachments: Optional[Iterable[Attachment]] = None, message_type: Optional[str] = None)
Assistant adds a message to the environment.
Source code in nearai/agents/environment.py
add_system_log ¶
Add system log with timestamp and log level.
Source code in nearai/agents/environment.py
add_user_memory ¶
call_agent ¶
clear_temp_agent_files ¶
Remove temp agent files created to be used in runpy
.
completion ¶
completion(messages: Union[Iterable[ChatCompletionMessageParam], str], model: Union[Iterable[ChatCompletionMessageParam], str] = '') -> str
Returns a completion for the given messages using the given model.
Source code in nearai/agents/environment.py
completion_and_run_tools ¶
completion_and_run_tools(messages: List[ChatCompletionMessageParam], model: str = '', tools: Optional[List] = None, **kwargs: Any) -> Optional[str]
Returns a completion for the given messages using the given model and runs tools.
Source code in nearai/agents/environment.py
completions ¶
completions(messages: Union[Iterable[ChatCompletionMessageParam], str], model: Union[Iterable[ChatCompletionMessageParam], str] = '', stream: bool = False, **kwargs: Any) -> Union[ModelResponse, CustomStreamWrapper]
Returns all completions for given messages using the given model.
Source code in nearai/agents/environment.py
completions_and_run_tools ¶
completions_and_run_tools(messages: List[ChatCompletionMessageParam], model: str = '', tools: Optional[List] = None, add_responses_to_messages: bool = True, agent_role_name='assistant', tool_role_name='tool', **kwargs: Any) -> ModelResponse
Returns all completions for given messages using the given model and runs tools.
Source code in nearai/agents/environment.py
create_snapshot ¶
Create an in memory snapshot.
Source code in nearai/agents/environment.py
create_vector_store ¶
create_vector_store(name: str, file_ids: list, expires_after: Union[ExpiresAfter, NotGiven] = NOT_GIVEN, chunking_strategy: Union[AutoFileChunkingStrategyParam, StaticFileChunkingStrategyParam, NotGiven] = NOT_GIVEN, metadata: Optional[Dict[str, str]] = None) -> VectorStore
Creates a vector store.
name: The name of the vector store.
file_ids: List of file ids to create the vector store.
chunking_strategy: The chunking strategy to use.
expires_after: The expiration policy.
metadata: Additional metadata.
VectorStore: The created vector store.
Source code in nearai/agents/environment.py
create_vector_store_from_source ¶
create_vector_store_from_source(name: str, source: Union[GitHubSource, GitLabSource], source_auth: Optional[str] = None, chunking_strategy: Optional[ChunkingStrategy] = None, expires_after: Optional[ExpiresAfter] = None, metadata: Optional[Dict[str, str]] = None) -> VectorStore
Creates a vector store from the given source.
name: The name of the vector store.
source: The source from which to create the vector store.
source_auth: The source authentication token.
chunking_strategy: The chunking strategy to use.
expires_after: The expiration policy.
metadata: Additional metadata.
VectorStore: The created vector store.
Source code in nearai/agents/environment.py
environment_run_info ¶
Returns the environment run information.
Source code in nearai/agents/environment.py
exec_command ¶
Executes a command in the environment and logs the output.
The environment does not allow running interactive programs. It will run a program for 1 second then will interrupt it if it is still running or if it is waiting for user input. command: The command to execute, like 'ls -l' or 'python3 tests.py'
Source code in nearai/agents/environment.py
generate_folder_hash_id ¶
Returns hash based on files and their contents in path, including subfolders.
Source code in nearai/agents/environment.py
generate_image ¶
get_agent_temp_path ¶
get_last_message ¶
Reads last message from the given role and returns it.
get_model_for_inference ¶
Returns 'provider::model_full_path'.
Source code in nearai/agents/environment.py
get_primary_agent_temp_dir ¶
get_system_path ¶
get_tool_registry ¶
get_tool_registry(new: bool = False) -> ToolRegistry
Returns the tool registry, a dictionary of tools that can be called by the agent.
get_vector_store ¶
list_files ¶
list_files_from_thread ¶
list_files_from_thread(order: Literal['asc', 'desc'] = 'asc', thread_id: Optional[str] = None) -> List[FileObject]
Lists files in the thread.
Source code in nearai/agents/environment.py
list_messages ¶
Backwards compatibility for chat_completions messages.
Source code in nearai/agents/environment.py
list_terminal_commands ¶
Returns the terminal commands from the terminal file.
Source code in nearai/agents/environment.py
load_snapshot ¶
Load Environment from Snapshot.
Source code in nearai/agents/environment.py
mark_failed ¶
Marks the environment run as failed.
Source code in nearai/agents/environment.py
query_user_memory ¶
query_vector_store ¶
Queries a vector store.
vector_store_id: The id of the vector store to query. query: The query to search for.
Source code in nearai/agents/environment.py
read_file ¶
Reads a file from the environment or thread.
Source code in nearai/agents/environment.py
read_file_by_id ¶
Read a file from the thread.
request_user_input ¶
Must be called to request input from the user.
Source code in nearai/agents/environment.py
run ¶
Runs agent(s) against a new or previously created environment.
Source code in nearai/agents/environment.py
run_agent ¶
run_agent(owner: str, agent_name: str, version: str, model: Optional[str] = None, query: Optional[str] = None, fork_thread: bool = True)
Runs a child agent on the thread.
Source code in nearai/agents/environment.py
set_next_actor ¶
Set the next actor / action in the dialogue.
Source code in nearai/agents/environment.py
upload_file ¶
upload_file(file_content: str, purpose: Literal['assistants', 'batch', 'fine-tune', 'vision'] = 'assistants')
Uploads a file to the registry.
verify_message ¶
verify_message(account_id: str, public_key: str, signature: str, message: str, nonce: str, callback_url: str) -> SignatureVerificationResult
Verifies that the user message is signed with NEAR Account.
Source code in nearai/agents/environment.py
write_file ¶
write_file(filename: str, content: Union[str, bytes], encoding: str = 'utf-8', filetype: str = 'text/plain', write_to_disk: bool = True) -> FileObject
Writes a file to the environment.
filename: The name of the file to write to content: The content to write to the file encoding: The encoding to use when writing the file (default is utf-8) filetype: The MIME type of the file (default is text/plain) write_to_disk: If True, write locally to disk (default is True)
Source code in nearai/agents/environment.py
tool_json_helper ¶
parse_json_args ¶
Parses LLM generated JSON args, trying various repair strategies if args are not valid JSON.
Source code in nearai/agents/tool_json_helper.py
parse_json_args_based_on_signature ¶
Finds parameter names based on the signature and tries to extract the values in between from the args string.
Source code in nearai/agents/tool_json_helper.py
tool_registry ¶
ToolRegistry ¶
A registry for tools that can be called by the agent.
Tool definitions follow this structure:
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
},
}
Source code in nearai/agents/tool_registry.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
call_tool ¶
get_all_tools ¶
get_tool ¶
get_tool_definition ¶
Get the definition of a tool by name.
Source code in nearai/agents/tool_registry.py
cli ¶
AgentCli ¶
Source code in nearai/cli.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
|
_create_new_agent ¶
Create a new agent from scratch.
Source code in nearai/cli.py
_fork_agent ¶
Fork an existing agent.
Source code in nearai/cli.py
_task ¶
_task(agents: str, task: str, thread_id: Optional[str] = None, tool_resources: Optional[Dict[str, Any]] = None, file_ids: Optional[List[str]] = None, last_message_id: Optional[str] = None, local: bool = False, env_vars: Optional[Dict[str, Any]] = None) -> Optional[str]
Runs agent non-interactively with a single task.
Source code in nearai/cli.py
create ¶
create(name: Optional[str] = None, description: Optional[str] = None, fork: Optional[str] = None) -> None
Create a new agent or fork an existing one.
Usage
nearai agent create nearai agent create --name
Examples¶
nearai agent create nearai agent create --name my_agent --description "My new agent" nearai agent create --fork agentic.near/summary/0.0.3 --name new_summary_agent
Source code in nearai/cli.py
inspect ¶
Inspect environment from given path.
interactive ¶
interactive(agents: str, thread_id: Optional[str] = None, tool_resources: Optional[Dict[str, Any]] = None, local: bool = False, env_vars: Optional[Dict[str, Any]] = None) -> None
Runs agent interactively.
Source code in nearai/cli.py
run_remote ¶
run_remote(agents: str, new_message: str = '', environment_id: str = '', provider: str = 'aws_lambda', params: object = None, framework: str = 'base', environment: str = 'production') -> None
Invoke a Container based AWS lambda function to run agents on a given environment.
Source code in nearai/cli.py
task ¶
task(agents: str, task: str, thread_id: Optional[str] = None, tool_resources: Optional[Dict[str, Any]] = None, file_ids: Optional[List[str]] = None, local: bool = False, env_vars: Optional[Dict[str, Any]] = None) -> None
CLI wrapper for the _task method.
Source code in nearai/cli.py
BenchmarkCli ¶
Source code in nearai/cli.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
|
__init__ ¶
list ¶
list(namespace: Optional[str] = None, benchmark: Optional[str] = None, solver: Optional[str] = None, args: Optional[str] = None, total: int = 32, offset: int = 0)
List all executed benchmarks.
Source code in nearai/cli.py
run ¶
run(dataset: str, solver_strategy: str, max_concurrent: int = 2, force: bool = False, subset: Optional[str] = None, check_compatibility: bool = True, record: bool = False, num_inference_retries: int = 10, **solver_args: Any) -> None
Run benchmark on a dataset with a solver strategy.
It will cache the results in the database and subsequent runs will pull the results from the cache. If force is set to True, it will run the benchmark again and update the cache.
Source code in nearai/cli.py
CLI ¶
Source code in nearai/cli.py
location ¶
submit ¶
Submit a task to be executed by a worker.
Source code in nearai/cli.py
task ¶
ConfigCli ¶
Source code in nearai/cli.py
get ¶
EvaluationCli ¶
Source code in nearai/cli.py
table ¶
table(all_key_columns: bool = False, all_metrics: bool = False, num_columns: int = 6, metric_name_max_length: int = 30) -> None
Prints table of evaluations.
Source code in nearai/cli.py
HubCLI ¶
Source code in nearai/cli.py
chat ¶
Chat with model from NearAI hub.
query (str): User's query to model
endpoint (str): NearAI HUB's url
model (str): Name of a model
provider (str): Name of a provider
info (bool): Display system info
kwargs (Dict[str, Any]): All cli keyword arguments
Source code in nearai/cli.py
LoginCLI ¶
Source code in nearai/cli.py
__call__ ¶
Login with NEAR Mainnet account.
remote (bool): Remote login allows signing message with NEAR Account on a remote machine
auth_url (str): Url to the auth portal
accountId (str): AccountId in .near-credentials folder to signMessage
privateKey (str): Private Key to sign a message
kwargs (Dict[str, Any]): All cli keyword arguments
Source code in nearai/cli.py
save ¶
Save NEAR account authorization data.
accountId (str): Near Account
signature (str): Signature
publicKey (str): Public Key used to sign
callbackUrl (str): Callback Url
nonce (str): nonce
kwargs (Dict[str, Any]): All cli keyword arguments
Source code in nearai/cli.py
LogoutCLI ¶
Source code in nearai/cli.py
__call__ ¶
Clear NEAR account auth data.
Source code in nearai/cli.py
PermissionCli ¶
Source code in nearai/cli.py
RegistryCli ¶
Source code in nearai/cli.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
download ¶
info ¶
Show information about an item.
Source code in nearai/cli.py
list ¶
list(namespace: str = '', category: str = '', tags: str = '', total: int = 32, offset: int = 0, show_all: bool = False, show_latest_version: bool = True, star: str = '') -> None
List available items.
Source code in nearai/cli.py
metadata_template ¶
Create a metadata template.
Source code in nearai/cli.py
update ¶
Update metadata of a registry item.
Source code in nearai/cli.py
upload ¶
upload(local_path: str = '.') -> EntryLocation
upload_unregistered_common_provider_models ¶
Creates new registry items for unregistered common provider models.
Source code in nearai/cli.py
check_update ¶
Check if there is a new version of nearai CLI available.
Source code in nearai/cli.py
config ¶
Config ¶
Bases: BaseModel
Source code in nearai/config.py
get ¶
update_with ¶
update_with(extra_config: Dict[str, Any], map_key: Callable[[str], str] = lambda x: x) -> Config
Update the config with the given dictionary.
Source code in nearai/config.py
NearAiHubConfig ¶
Bases: BaseModel
NearAiHub Config.
login_with_near (Optional[bool]): Indicates whether to attempt login using Near Auth.
api_key (Optional[str]): The API key to use if Near Auth is not being utilized
base_url (Optional[str]): NearAI Hub url
default_provider (Optional[str]): Default provider name
default_model (Optional[str]): Default model name
custom_llm_provider (Optional[str]): provider to be used by litellm proxy
Source code in nearai/config.py
dataset ¶
get_dataset ¶
Download the dataset from the registry and download it locally if it hasn't been downloaded yet.
:param name: The name of the entry to download the dataset. The format should be namespace/name/version. :return: The path to the downloaded dataset
Source code in nearai/dataset.py
load_dataset ¶
delegation ¶
OnBehalfOf ¶
Create a context manager that allows you to delegate actions to another account.
with OnBehalfOf("scheduler.ai"):
# Upload is done on behalf of scheduler.ai
# If delegation permission is not granted, this will raise an exception
registry.upload()
Source code in nearai/delegation.py
__enter__ ¶
Set the default client to the account we are acting on behalf of.
Source code in nearai/delegation.py
__exit__ ¶
Reset the default client to the original account.
__init__ ¶
Context manager that creates a scope where all actions are done on behalf of another account.
check_on_behalf_of ¶
revoke_delegation ¶
evaluation ¶
_print_metrics_tables ¶
_print_metrics_tables(rows: List[Dict[str, str]], metric_names: List[str], num_columns: int, all_key_columns: bool, metric_name_max_length: int)
Builds table(s) and prints them.
Source code in nearai/evaluation.py
_shorten_metric_name ¶
Shortens metric name if needed.
Source code in nearai/evaluation.py
print_evaluation_table ¶
print_evaluation_table(rows: List[Dict[str, str]], columns: List[str], important_columns: List[str], all_key_columns: bool, all_metrics: bool, num_columns: int, metric_name_max_length: int) -> None
Prints table of evaluations.
Source code in nearai/evaluation.py
record_evaluation_metrics ¶
record_evaluation_metrics(solver_strategy: SolverStrategy, metrics: Dict[str, Any], prepend_evaluation_name: bool = True) -> None
Uploads evaluation metrics into registry.
Source code in nearai/evaluation.py
record_single_score_evaluation ¶
record_single_score_evaluation(solver_strategy: SolverStrategy, score: float) -> None
Uploads single score evaluation into registry.
Source code in nearai/evaluation.py
upload_evaluation ¶
upload_evaluation(evaluation_name: str, metrics: Dict[str, Any], model: str = '', agent: str = '', namespace: str = '', version: str = '', provider: str = '') -> None
Uploads evaluation into registry.
evaluation_name
: a unique name for (benchmark, solver) tuple, e.g. "mbpp" or "live_bench" or "mmlu-5-shot". metrics
: metrics from evaluation. model
: model that was used. agent
: agent that was evaluated, in any. namespace
: namespace of evaluated agent or evaluated model. version
: version of evaluated agent or evaluated model. provider
: provider of model used; pass local
if running locally.
Source code in nearai/evaluation.py
finetune ¶
FinetuneCli ¶
Source code in nearai/finetune/__init__.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
start ¶
start(model: str, tokenizer: str, dataset: str, num_procs: int, format: str, upload_checkpoint: bool = True, num_nodes: int = 1, job_id: Optional[str] = None, checkpoint: Optional[str] = None, **dataset_kwargs: Any) -> None
Start a finetuning job on the current node.
model: Name of a model in the registry. Base model to finetune.
tokenizer: Name of a tokenizer in the registry. Using tokenizer.model format.
dataset: Name of a dataset in the registry.
num_procs: Number of GPUs to use for training
format: Name of the configuration file to use. For example llama3-70b, llama3-8b. Valid options are in etc/finetune.
upload_checkpoint: Whether to upload the checkpoint to the registry. Default is True.
num_nodes: Number of nodes to use for training. Default is 1.
job_id: Unique identifier for the job. Default is None.
checkpoint: Name of the model checkpoint to start from. Default is None.
dataset_kwargs: Additional keyword arguments to pass to the dataset constructor.
Source code in nearai/finetune/__init__.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
parse_line ¶
Example of line to be parsed.
Step 33 | loss:1.5400923490524292 lr:9.9e-05 tokens_per_second_per_gpu:101.22285588141214
Source code in nearai/finetune/__init__.py
text_completion ¶
TextCompletionDataset ¶
Bases: Dataset
Freeform dataset for any unstructured text corpus. Quickly load any dataset from Hugging Face or local disk and tokenize it for your model.
tokenizer (BaseTokenizer): Tokenizer used to encode data. Tokenize must implement an ``encode`` and ``decode`` method.
source (str): path string of dataset, anything supported by Hugging Face's ``load_dataset``
(https://huggingface.co/docs/datasets/en/package_reference/loading_methods#datasets.load_dataset.path)
column (str): name of column in the sample that contains the text data. This is typically required
for Hugging Face datasets or tabular data. For local datasets with a single column, use the default "text",
which is what is assigned by Hugging Face datasets when loaded into memory. Default is "text".
max_seq_len (Optional[int]): Maximum number of tokens in the returned input and label token id lists.
Default is None, disabling truncation. We recommend setting this to the highest you can fit in memory
and is supported by the model. For example, llama2-7B supports up to 4096 for sequence length.
**load_dataset_kwargs (Dict[str, Any]): additional keyword arguments to pass to ``load_dataset``.
Source code in nearai/finetune/text_completion.py
truncate ¶
Truncate a list of tokens to a maximum length. If eos_id is provided, the last token will be replaced with eos_id.
tokens (List[Any]): list of tokens to truncate
max_seq_len (int): maximum length of the list
eos_id (Optional[Any]): token to replace the last token with. If None, the
last token will not be replaced. Default is None.
List[Any]: truncated list of tokens
Source code in nearai/finetune/text_completion.py
hub ¶
Hub ¶
Bases: object
Source code in nearai/hub.py
chat ¶
Processes a chat request by sending parameters to the NearAI Hub and printing the response.
Source code in nearai/hub.py
parse_hub_chat_params ¶
Parses and sets instance attributes from the given keyword arguments, using default values if needed.
Source code in nearai/hub.py
lib ¶
parse_location ¶
parse_location(entry_location: str) -> EntryLocation
Create a EntryLocation from a string in the format namespace/name/version.
Source code in nearai/lib.py
login ¶
AuthHandler ¶
Bases: SimpleHTTPRequestHandler
Source code in nearai/login.py
do_GET ¶
Webserver GET method.
Source code in nearai/login.py
find_open_port ¶
Finds and returns an open port number by binding to a free port on the local machine.
generate_and_save_signature ¶
Generates a signature for the given account ID and private key, then updates the auth configuration.
Source code in nearai/login.py
generate_callback_url ¶
generate_nonce ¶
login_with_file_credentials ¶
Logs in using credentials from a file for the specified account ID, generating and saving a signature.
Source code in nearai/login.py
login_with_near_auth ¶
Initiates the login process using NEAR authentication, either starting a local server to handle the callback or providing a URL for remote authentication.
Source code in nearai/login.py
print_login_status ¶
Prints the current authentication status if available in the config file.
Source code in nearai/login.py
print_url_message ¶
Prints a message instructing the user to visit the given URL to complete the login process.
update_auth_config ¶
Update authentication configuration if the provided signature is valid.
Source code in nearai/login.py
model ¶
get_model ¶
Download the model from the registry and download it locally if it hasn't been downloaded yet.
:param name: The name of the entry to download the model. The format should be namespace/name/version. :return: The path to the downloaded model
Source code in nearai/model.py
registry ¶
Registry ¶
Source code in nearai/registry.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
__init__ ¶
Create Registry object to interact with the registry programmatically.
Source code in nearai/registry.py
dict_models ¶
dict_models() -> Dict[NamespacedName, NamespacedName]
Returns a mapping canonical->name.
Source code in nearai/registry.py
download ¶
download(entry_location: Union[str, EntryLocation], force: bool = False, show_progress: bool = False, verbose: bool = True) -> Path
Download entry from the registry locally.
Source code in nearai/registry.py
download_file ¶
download_file(entry_location: EntryLocation, path: Path, local_path: Path)
Download a file from the registry.
Source code in nearai/registry.py
info ¶
info(entry_location: EntryLocation) -> Optional[EntryMetadata]
Get metadata of a entry in the registry.
Source code in nearai/registry.py
list ¶
list(namespace: str, category: str, tags: str, total: int, offset: int, show_all: bool, show_latest_version: bool, starred_by: str = '') -> List[EntryInformation]
List and filter entries in the registry.
Source code in nearai/registry.py
list_all_visible ¶
List all visible entries.
Source code in nearai/registry.py
list_files ¶
list_files(entry_location: EntryLocation) -> List[str]
List files in from an entry in the registry.
Return the relative paths to all files with respect to the root of the entry.
Source code in nearai/registry.py
update ¶
update(entry_location: EntryLocation, metadata: EntryMetadataInput) -> Dict[str, Any]
Update metadata of a entry in the registry.
Source code in nearai/registry.py
upload ¶
upload(local_path: Path, metadata: Optional[EntryMetadata] = None, show_progress: bool = False) -> EntryLocation
Upload entry to the registry.
If metadata is provided it will overwrite the metadata in the directory, otherwise it will use the metadata.json found on the root of the directory.
Source code in nearai/registry.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
upload_file ¶
upload_file(entry_location: EntryLocation, local_path: Path, path: Path) -> bool
Upload a file to the registry.
Source code in nearai/registry.py
get_namespace ¶
Returns namespace of an item or user namespace.
Source code in nearai/registry.py
shared ¶
auth_data ¶
AuthData ¶
Bases: BaseModel
Source code in nearai/shared/auth_data.py
namespace property
¶
Get the account ID for the auth data.
In case you are running a request on behalf of another account, this will return the account ID of the account.
generate_bearer_token ¶
Generates a JSON-encoded bearer token containing authentication data.
Source code in nearai/shared/auth_data.py
cache ¶
mem_cache_with_timeout ¶
Decorator to cache function results for a specified timeout period.
Source code in nearai/shared/cache.py
client_config ¶
ClientConfig ¶
Bases: BaseModel
Source code in nearai/shared/client_config.py
get_hub_client ¶
Get the hub client.
Source code in nearai/shared/client_config.py
inference_client ¶
InferenceClient ¶
Bases: object
Source code in nearai/shared/inference_client.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
add_file_to_vector_store ¶
Adds a file to vector store.
Source code in nearai/shared/inference_client.py
add_user_memory ¶
completions ¶
completions(model: str, messages: Iterable[ChatCompletionMessageParam], stream: bool = False, temperature: Optional[float] = None, max_tokens: Optional[int] = None, **kwargs: Any) -> Union[ModelResponse, CustomStreamWrapper]
Takes a model
and messages
and returns completions.
model
can be: 1. full path provider::model_full_path
. 2. model_short_name
. Default provider will be used.
Source code in nearai/shared/inference_client.py
create_thread ¶
create_vector_store ¶
create_vector_store(name: str, file_ids: List[str], expires_after: Union[ExpiresAfter, NotGiven] = NOT_GIVEN, chunking_strategy: Union[AutoFileChunkingStrategyParam, StaticFileChunkingStrategyParam, NotGiven] = NOT_GIVEN, metadata: Optional[Dict[str, str]] = None) -> VectorStore
Creates Vector Store.
:param name: Vector store name. :param file_ids: Files to be added to the vector store. :param expires_after: Expiration policy. :param chunking_strategy: Chunking strategy. :param metadata: Additional metadata. :return: Returns the created vector store or error.
Source code in nearai/shared/inference_client.py
create_vector_store_from_source ¶
create_vector_store_from_source(name: str, source: Union[GitHubSource, GitLabSource], source_auth: Optional[str] = None, chunking_strategy: Optional[ChunkingStrategy] = None, expires_after: Optional[ExpiresAfter] = None, metadata: Optional[Dict[str, str]] = None) -> VectorStore
Creates a vector store from the given source.
name (str): The name of the vector store.
source (Union[GitHubSource, GitLabSource]): The source from which to create the vector store.
source_auth (Optional[str]): The source authentication token.
chunking_strategy (Optional[ChunkingStrategy]): The chunking strategy to use.
expires_after (Optional[ExpiresAfter]): The expiration policy.
metadata (Optional[Dict[str, str]]): Additional metadata.
VectorStore: The created vector store.
Source code in nearai/shared/inference_client.py
generate_image ¶
get_vector_store ¶
Gets a vector store by id.
Source code in nearai/shared/inference_client.py
query_user_memory ¶
query_vector_store ¶
Query a vector store.
Source code in nearai/shared/inference_client.py
run_agent ¶
Starts a child agent run from a parent agent run.
Source code in nearai/shared/inference_client.py
threads_create_and_run_poll ¶
threads_create_and_run_poll(assistant_id: str, model: str, messages: List[ChatCompletionMessageParam])
Create a thread and run the assistant.
Source code in nearai/shared/inference_client.py
threads_fork ¶
threads_list_messages ¶
threads_messages_create ¶
Create a message in a thread.
threads_runs_create ¶
Create a run in a thread.
upload_file ¶
upload_file(file_content: str, purpose: Literal['assistants', 'batch', 'fine-tune', 'vision'], encoding: str = 'utf-8', file_name='file.txt', file_type='text/plain') -> FileObject
Uploads a file.
Source code in nearai/shared/inference_client.py
models ¶
AutoFileChunkingStrategyParam ¶
ChunkingStrategy ¶
CreateVectorStoreRequest ¶
Bases: BaseModel
Request model for creating a new vector store.
Source code in nearai/shared/models.py
chunking_strategy class-attribute
instance-attribute
¶
chunking_strategy: Optional[ChunkingStrategy] = None
The chunking strategy to use for the vector store.
expires_after class-attribute
instance-attribute
¶
expires_after: Optional[ExpiresAfter] = None
The expiration time for the vector store.
file_ids class-attribute
instance-attribute
¶
The file IDs to attach to the vector store.
metadata class-attribute
instance-attribute
¶
The metadata to attach to the vector store.
ExpiresAfter ¶
Bases: TypedDict
Source code in nearai/shared/models.py
StaticFileChunkingStrategyParam ¶
Bases: TypedDict
Source code in nearai/shared/models.py
chunk_overlap_tokens instance-attribute
¶
The number of tokens that overlap between chunks. The default value is 400
.
Note that the overlap must not exceed half of max_chunk_size_tokens
.
max_chunk_size_tokens instance-attribute
¶
The maximum number of tokens in each chunk.
The default value is 800
. The minimum value is 100
and the maximum value is 4096
.
VectorStoreFileCreate ¶
Bases: BaseModel
Request model for creating a vector store file.
Source code in nearai/shared/models.py
naming ¶
NamespacedName ¶
Source code in nearai/shared/naming.py
canonical ¶
canonical() -> NamespacedName
Returns canonical NamespacedName.
Source code in nearai/shared/naming.py
create_registry_name ¶
Formats name
for a suitable registry name.
Source code in nearai/shared/naming.py
get_canonical_name ¶
Returns a name that can be used for matching entities.
Applies such transformations: 1. All letters lowercase. 2. Convert '.' between digits to 'p'. 3. Convert '
e.g. "llama-3.1-70b-instruct" -> "llama3p1_70binstruct"
Source code in nearai/shared/naming.py
near ¶
sign ¶
SignatureVerificationResult ¶
Bases: Enum
Source code in nearai/shared/near/sign.py
convert_nonce ¶
Converts a given value to a 32-byte nonce.
Source code in nearai/shared/near/sign.py
create_signature ¶
Creates a cryptographic signature for a given payload using a specified private key.
Source code in nearai/shared/near/sign.py
validate_nonce ¶
Ensures that the nonce is a valid timestamp.
Source code in nearai/shared/near/sign.py
validate_signature ¶
Validates a cryptographic signature for a given payload using a specified public key.
Source code in nearai/shared/near/sign.py
verify_access_key_owner ¶
verify_access_key_owner(public_key, account_id) -> SignatureVerificationResult
Verifies if a given public key belongs to a specified account ID using FastNEAR API.
Source code in nearai/shared/near/sign.py
verify_signed_message ¶
verify_signed_message(account_id, public_key, signature, message, nonce, recipient, callback_url) -> SignatureVerificationResult
Verifies a signed message and ensures the public key belongs to the specified account.
Source code in nearai/shared/near/sign.py
provider_models ¶
ProviderModels ¶
Source code in nearai/shared/provider_models.py
provider_models property
¶
provider_models: Dict[NamespacedName, Dict[str, str]]
Returns a mapping canonical->provider->model_full_name.
available_provider_matches ¶
available_provider_matches(model: NamespacedName) -> Dict[str, str]
get_unregistered_common_provider_models ¶
get_unregistered_common_provider_models(registry_models: Dict[NamespacedName, NamespacedName]) -> List[Dict[str, str]]
Returns provider matches for unregistered provider models with default namespace.
Source code in nearai/shared/provider_models.py
match_provider_model ¶
Returns provider and model_full_path for given model
and optional provider
.
model
may take different formats. Supported ones: 1. model_full_path, e.g. "fireworks::accounts/yi-01-ai/models/yi-large" 2. model_full_path without provider, e.g. "accounts/yi-01-ai/models/yi-large" 3. model_short_name as used by provider, e.g. "llama-v3-70b-instruct" 4. namespace/model_short_name as used by provider, e.g. "yi-01-ai/yi-large" 5. model_name as used in registry, e.g. "llama-3-70b-instruct" 6. namespace/model_name as used in registry, e.g. "near.ai/llama-3-70b-instruct"
Source code in nearai/shared/provider_models.py
get_provider_model ¶
Splits the model
string based on a predefined separator and returns the components.
provider (Optional[str]): The default provider name. Can be `None` if the provider
is included in the `model` string.
model (str): The model identifier, which may include the provider name separated by
a specific delimiter (defined by `PROVIDER_MODEL_SEP`, e.g. `::`).
Source code in nearai/shared/provider_models.py
get_provider_namespaced_model ¶
get_provider_namespaced_model(provider_model: str, provider: Optional[str] = None) -> Tuple[str, NamespacedName]
Given provider_model
returns provider and namespaced model.
Source code in nearai/shared/provider_models.py
solvers ¶
DDOTSV0Solver ¶
Bases: SolverStrategy
Solver strategy for competitive programming problems live on DDOTS.
This dataset will run agents in an Agent environment previously prepared.
workspace/ .id -- Id of the problem PROBLEM.txt -- Description of the problem
The agent should call env.submit_python(code) to submit the code to the DDOTS server.
Source code in nearai/solvers/ddot_v0_solver.py
GSM8KSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the GSM8K dataset.
Source code in nearai/solvers/gsm8k_solver.py
HellaswagSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/hellaswag_solver.py
LeanSolverStrategy ¶
Bases: SolverStrategy
Solver strategy to evaluate against Lean problems.
Source code in nearai/solvers/lean_solver.py
LiveBenchSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the live bench dataset.
Source code in nearai/solvers/livebench_solver.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
MBPPSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MBPP dataset.
Source code in nearai/solvers/mbpp_solver.py
MMLUSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/mmlu_solver.py
SolverStrategy ¶
Bases: ABC
Abstract class for solver strategies.
Source code in nearai/solvers/__init__.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
agent_name ¶
agent_version ¶
compatible_datasets abstractmethod
¶
evaluated_entry_namespace ¶
Returns namespace of a model or agent to be evaluated.
evaluation_name abstractmethod
¶
Returns a unique name for (benchmark, solver) tuple, e.g. 'mbpp' or 'live_bench' or 'mmlu-5-shot'.
get_custom_tasks ¶
Custom tasks for custom benchmark.
Source code in nearai/solvers/__init__.py
get_evaluation_metrics ¶
Given results for all datums, returns evaluation metrics.
Not used by TrueOrFalseList scoring method. Do not prepend with evaluation_name. If hierarchical, use slashes /. Expected metrics is a dict of scores, e.g.: {"average":
Source code in nearai/solvers/__init__.py
model_provider ¶
Returns model provider.
Source code in nearai/solvers/__init__.py
SolverStrategyMeta ¶
Bases: ABCMeta
Metaclass that automatically registers subclasses in the SolverStrategyRegistry.
Source code in nearai/solvers/__init__.py
ddot_v0_solver ¶
DDOTSEnvironment ¶
Bases: Environment
Source code in nearai/solvers/ddot_v0_solver.py
submit_python ¶
Returns True if the submission was accepted, False otherwise.
The second element of the tuple is the output of the checker if the submission was rejected.
Source code in nearai/solvers/ddot_v0_solver.py
DDOTSV0Solver ¶
Bases: SolverStrategy
Solver strategy for competitive programming problems live on DDOTS.
This dataset will run agents in an Agent environment previously prepared.
workspace/ .id -- Id of the problem PROBLEM.txt -- Description of the problem
The agent should call env.submit_python(code) to submit the code to the DDOTS server.
Source code in nearai/solvers/ddot_v0_solver.py
gsm8k_solver ¶
GSM8KSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the GSM8K dataset.
Source code in nearai/solvers/gsm8k_solver.py
hellaswag_solver ¶
HellaswagSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/hellaswag_solver.py
lean_solver ¶
LeanSolverStrategy ¶
Bases: SolverStrategy
Solver strategy to evaluate against Lean problems.
Source code in nearai/solvers/lean_solver.py
load_theorem ¶
Use local copy of the repository.
livebench_solver ¶
LiveBenchSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the live bench dataset.
Source code in nearai/solvers/livebench_solver.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
mbpp_solver ¶
MBPPSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MBPP dataset.
Source code in nearai/solvers/mbpp_solver.py
mmlu_solver ¶
MMLUSolverStrategy ¶
Bases: SolverStrategy
Solver strategy for the MMLU dataset.
Source code in nearai/solvers/mmlu_solver.py
tests ¶
test_provider_models ¶
TestMatchProviderModel ¶
Bases: TestCase
Unit tests for get_provider_namespaced_model.