Skip to content

an open source large language model function call framework, use it to easily build your ai assistant and integrate with your own functions

License

Notifications You must be signed in to change notification settings

XiaooLei/open-function-call

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open Function Call framework

The Open Function Call framework is a Python-based large language model function call framework that allows users to build ai assistant quickly and privide ability similar to OpenAI assistant function call api.

Getting Started

Prerequisites

  • Python 3.x

Installation

  1. Clone the repository:

    git clone https://github.com/XiaooLei/open-function-call.git
    cd open-function-call
    

Usage

  1. Import the necessary modules in your script:
from open_function_call import Assistant
  1. Define your tool list with functions:
tool_list = [
    {
        "type": "function",
        "function": {
            "name": "browser",
            "description": "search information from the internet",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {
                        "type": "string",
                        "description": "the query you need to search",
                    },
                },
                "required": ["query"],
            },
        }
    }
]
  1. Create instances of necessary classes and run the assistant, demo:
glm = GLMHttpClient() # this could be any llm interface like Llama, Chat-GLM...
assistant = Assistant(tool_list=tool_list, llm=glm)

user_input = input(">> ")
while True:
    assistant.human_ask(user_input)
    cur = assistant.run()
    if cur["type"] == "function_call":
        if cur["function_name"] == "browser":
            print("call function..., args:", cur["arguments"])
            arguments = cur["arguments"]
            browser_output = baidu_search(arguments["query"])
            assistant.submit_function_res(browser_output)

    elif cur["type"] == "reply":
        print("AI:", cur["ai_msg"])
        user_input = input(">> ")

Contributing

If you'd like to contribute to this project, please follow the contribution guidelines.

About

an open source large language model function call framework, use it to easily build your ai assistant and integrate with your own functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages