Coder Social home page Coder Social logo

suhib97 / agentscope Goto Github PK

View Code? Open in Web Editor NEW

This project forked from modelscope/agentscope

0.0 1.0 0.0 34.96 MB

Start building LLM-empowered multi-agent applications in an easier way.

Home Page: https://modelscope.github.io/agentscope/

License: Apache License 2.0

Shell 0.12% JavaScript 27.57% Python 64.11% CSS 2.35% HTML 3.13% Jupyter Notebook 2.73%

agentscope's Introduction

English | 中文

AgentScope

Start building LLM-empowered multi-agent applications in an easier way.

If you find our work helpful, please kindly cite our paper.

Welcome to join our community on

Discord DingTalk WeChat

News


What's AgentScope?

AgentScope is an innovative multi-agent platform designed to empower developers to build multi-agent applications with large-scale models. It features three high-level capabilities:

  • 🤝 Easy-to-Use: Designed for developers, with fruitful components, comprehensive documentation, and broad compatibility.

  • High Robustness: Supporting customized fault-tolerance controls and retry mechanisms to enhance application stability.

  • 🚀 Actor-Based Distribution: Building distributed multi-agent applications in a centralized programming manner for streamlined development.

Supported Model Libraries

AgentScope provides a list of ModelWrapper to support both local model services and third-party model APIs.

API Task Model Wrapper Example Configuration
OpenAI API Chat OpenAIChatWrapper link
Embedding OpenAIEmbeddingWrapper link
DALL·E OpenAIDALLEWrapper link
DashScope API Chat DashScopeChatWrapper link
Image Synthesis DashScopeImageSynthesisWrapper link
Text Embedding DashScopeTextEmbeddingWrapper link
Gemini API Chat GeminiChatWrapper link
Embedding GeminiEmbeddingWrapper link
ollama Chat OllamaChatWrapper link
Embedding OllamaEmbeddingWrapper link
Generation OllamaGenerationWrapper link
Post Request based API - PostAPIModelWrapper link

Supported Local Model Deployment

AgentScope enables developers to rapidly deploy local model services using the following libraries.

Supported Services

  • Web Search
  • Data Query
  • Retrieval
  • Code Execution
  • File Operation
  • Text Processing

Example Applications

More models, services and examples are coming soon!

Installation

AgentScope requires Python 3.9 or higher.

Note: This project is currently in active development, it's recommended to install AgentScope from source.

From source

  • Install AgentScope in editable mode:
# Pull the source code from GitHub
git clone https://github.com/modelscope/agentscope.git

# Install the package in editable mode
cd agentscope
pip install -e .
  • To build distributed multi-agent applications:
# On windows
pip install -e .[distribute]
# On mac
pip install -e .\[distribute\]

Using pip

  • Install AgentScope from pip:
pip install agentscope

Quick Start

Configuration

In AgentScope, the model deployment and invocation are decoupled by ModelWrapper.

To use these model wrappers, you need to prepare a model config file as follows.

model_config = {
    # The identifies of your config and used model wrapper
    "config_name": "{your_config_name}",          # The name to identify the config
    "model_type": "{model_type}",                 # The type to identify the model wrapper

    # Detailed parameters into initialize the model wrapper
    # ...
}

Taking OpenAI Chat API as an example, the model configuration is as follows:

openai_model_config = {
    "config_name": "my_openai_config",             # The name to identify the config
    "model_type": "openai",                        # The type to identify the model wrapper

    # Detailed parameters into initialize the model wrapper
    "model_name": "gpt-4",                         # The used model in openai API, e.g. gpt-4, gpt-3.5-turbo, etc.
    "api_key": "xxx",                              # The API key for OpenAI API. If not set, env
                                                   # variable OPENAI_API_KEY will be used.
    "organization": "xxx",                         # The organization for OpenAI API. If not set, env
                                                   # variable OPENAI_ORGANIZATION will be used.
}

More details about how to set up local model services and prepare model configurations is in our tutorial.

Create Agents

Create built-in user and assistant agents as follows.

from agentscope.agents import DialogAgent, UserAgent
import agentscope

# Load model configs
agentscope.init(model_configs="./model_configs.json")

# Create a dialog agent and a user agent
dialog_agent = DialogAgent(name="assistant",
                           model_config_name="my_openai_config")
user_agent = UserAgent()

Construct Conversation

In AgentScope, message is the bridge among agents, which is a dict that contains two necessary fields name and content and an optional field url to local files (image, video or audio) or website.

from agentscope.message import Msg

x = Msg(name="Alice", content="Hi!")
x = Msg("Bob", "What about this picture I took?", url="/path/to/picture.jpg")

Start a conversation between two agents (e.g. dialog_agent and user_agent) with the following code:

x = None
while True:
    x = dialog_agent(x)
    x = user_agent(x)
    if x.content == "exit":  # user input "exit" to exit the conversation_basic
        break

AgentScope Studio

AgentScope provides an easy-to-use runtime user interface capable of displaying multimodal output on the front end, including text, images, audio and video. To start a studio, you should install the full version of AgentScope.

# On windows
pip install -e .[full]
# On mac
pip install -e .\[full\]

Once installed, you can just run

as_studio  path/to/your/script.py

Then the studio will be launched at localhost:xxxx, and you can see the UI similar to the following: To be able to use the as_studio functionality, please implement the main function in your code. More detail can be found in src/agentscope/web/README.md.

Tutorial

License

AgentScope is released under Apache License 2.0.

Contributing

Contributions are always welcomed!

We provide a developer version with additional pre-commit hooks to perform checks compared to the official version:

# For windows
pip install -e .[dev]
# For mac
pip install -e .\[dev\]

# Install pre-commit hooks
pre-commit install

Please refer to our Contribution Guide for more details.

References

If you find our work helpful for your research or application, please cite our paper:

@article{agentscope,
  author  = {Dawei Gao and
             Zitao Li and
             Weirui Kuang and
             Xuchen Pan and
             Daoyuan Chen and
             Zhijian Ma and
             Bingchen Qian and
             Liuyi Yao and
             Lin Zhu and
             Chen Cheng and
             Hongzhu Shi and
             Yaliang Li and
             Bolin Ding and
             Jingren Zhou},
  title   = {AgentScope: A Flexible yet Robust Multi-Agent Platform},
  journal = {CoRR},
  volume  = {abs/2402.14034},
  year    = {2024},
}

agentscope's People

Contributors

davdgao avatar pan-x-c avatar qbc2016 avatar rayrayraykk avatar zitao-li avatar yxdyc avatar eltociear avatar osier-yi avatar zwjaaa avatar xiaojinwhu avatar garyzhang99 avatar wangwangbobo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.