Coder Social home page Coder Social logo

aiserver's Introduction

Amazon Bedrock Knowledge base hosting server

功能说明

提供API, 对接Amazon Bedrock 和 Knowledge base for Amazon Bedrock

/api/log
/api/bedrock/rag
/api/bedrock/rag_with_rewrite
/api/bedrock/chat
/api/config
/api/config/<item_key>
/api/config
/api/asr/test
/api/asr/job
/api/asr/update_asr_job
/api/asr/asr_result

提供配置修改能力

img.png

提供测试页面

img_1.png

部署和启动

config.json 程序配置文件, 里面关联的是程序启动时候需要的region信息等, 服务启动后不可更改

app config

此部分配置存在于Dynamic表中,可以修改

how to deploy?

Download yaml template and upload as CloudFormation

Get the url from Stack output and copy it to browser

部署成功后

服务启动在5000端口

  1. 拿到alb的访问路径, 直接访问
  2. http://{alb.domain}/api/bedrock/chat #调用Amazon Bedrock托管的Sonnet模型
export ACCESS_KEY=xxx
export SECRET_KEY=xxx
./start_server.sh

几个本地测试的例子

## 测试访问知识库



## 从英文资料获取的答案
curl -X POST \
     http://localhost:5000/suggest \
     -H "Content-Type: application/json" \
     -H "Authorization: Basic xxxxx=" \
     -d @- << EOF
{
  "input": "购买后几天可以退货?",
  "filter": {
        "equals": {
            "key": "language",
            "value": "japanese"
        }
    }
}
EOF

# answer
{
  "result": {
    "text": "根据搜索结果,我没有找到关于这款产品的退货政策的具体信息。搜索结果主要介绍了产品的一些技术参数和特点,但没有提及退货期限。"
  }
}


## 从日语资料库获取的答案
curl -X POST \
     http://localhost:5000/suggest \
     -H "Content-Type: application/json" \
     -H "Authorization: Basic xxxxx=" \
     -d @- << EOF
{
  "input": "购买后几天可以退货?",
  "filter": {
        "equals": {
            "key": "language",
            "value": "english"
        }
    }
}
EOF
# answer
{
  "result": {
    "text": "根据搜索结果,如果您想退货,必须在收到货物后的30天内申请退货。一旦收到退货包裹,Jackery将在2-4个工作日内将款项退还至您的原始付款方式。"
  }
}




curl -X POST \
     -H "Content-Type: application/json" \
     -H "Authorization: Basic YWRtaW46cGFzc3dvcmQxMjM=" \
     -d '{"input": "翻译以下内容为日语:购买后几天可以退货?", "market":"Japan"}' \
     http://localhost:5000/suggest
     
     
#with prompt
curl -X POST \
     -H "Content-Type: application/json" \
     -H "Authorization: Basic YWRtaW46cGFzc3dvcmQxMjM=" \
     -d '{"input": "翻译以下内容为日语:购买后几天可以退货?", "market":"Japan", "prompt":"test"}' \
     http://localhost:5000/suggest

# without tempalte
curl -X POST \
     -H "Content-Type: application/json" \
     -H "Authorization: Basic YWRtaW46cGFzc3dvcmQxMjM=" \
     -d '{"input": "购买后几天可以退货?", "market":"Japan"}' \
     http://localhost:5000/suggest
     
# 测试直接调用模型
curl -X POST -H "Content-Type: application/json" -d '{"input": "翻译以下内容为日语:购买后几天可以退货?"}' http://localhost:5000/chat

ASR Job Test

curl -X POST \
  http://localhost:5000/api/asr/job \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic YWRtaW46KGBnSHBOfjI=" \
  -d @- <<EOF
{
"mp4_url": "s3://aigc.red.plaza/huabao/Ticket #593149recording.mp3",
"language": "ja-JP"
}
EOF


curl -X POST \
  http://localhost:5000/api/asr/update_asr_job \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic YWRtaW46KGBnSHBOfjI=" \
  -d @- <<EOF
{
"job_name": "asr_ca4961b3-4a24-4bcb-90c5-c73d981e2000"
}
EOF


curl -X POST \
  http://localhost:5000/api/asr/update_asr_job \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic YWRtaW46KGBnSHBOfjI=" \
  -d @- <<EOF
{
"job_name": "asr_7966a124-4612-4fb9-8544-a59718c36f93"
}
EOF

aiserver's People

Contributors

nimysan avatar

Stargazers

 avatar

Watchers

 avatar Kostas Georgiou avatar

aiserver's Issues

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.