OpenMOSS / MOSS

An open-source tool-augmented conversational language model from Fudan University
https://txsun1997.github.io/blogs/moss.html
Apache License 2.0
11.92k stars 1.14k forks source link

Added Multi-round chat API demo #248

Closed sunyuhan19981208 closed 1 year ago

sunyuhan19981208 commented 1 year ago

This pull request adds a new API demo for a multi-round chat feature to the moss project.

The new demo allows users to engage in multiple rounds of conversation with a chatbot and provides a unique uid for each round. The uid is used to keep track of the conversation history for each round.

To use the multi-round chat feature, users can send a POST request:

## curl moss
curl -X POST "http://0.0.0.0:19324" \
     -H 'Content-Type: application/json' \
     -d '{"prompt": "你是谁?"}'

The chatbot will respond with a JSON object containing the conversation history for the current round:

## curl moss
curl -X POST "http://0.0.0.0:19324" \
     -H 'Content-Type: application/json' \
     -d '{"prompt": "你是谁?"}'

Users can fill the uid if you want to have a multi-round chat with moss:

## curl moss multi-round
curl -X POST "http://0.0.0.0:19324" \
     -H 'Content-Type: application/json' \
     -d '{"prompt": "你是谁?", "uid":"10973cfc-85d4-4b7b-a56a-238f98689d47"}'

Changes Made Added a new moss_api_demo.py file to the the moss project. Documentation Updated the moss repository README to include a note about the new api demo.