用户画像(https://github.com/memodb-io/memobase)应用

1.下载项目的源代码,我们要先启动后端,用docker启动

cd src/server
cp .env.example .env
cp ./api/config.yaml.example ./api/config.yaml

这里我的配置内容如下config.yaml(因为我是调用的符合openai格式的大模型,所以我没改,如果要是别的大模型的话,需要自己再做兼容)

llm_api_key: sk-
llm_base_url: https://openrouter.ai/api/v1
llm_style: openai
best_llm_model: google/gemini-2.5-pro-exp-03-25:free

用户画像(https://github.com/memodb-io/memobase)应用_第1张图片

在图中框出来的地方做兼容,openrouter.py是我新加的

然后配置好后

docker-compose build && docker-compose up

 后端启动成功,然后我们测试一下,访问,http://101.43.194.123:8019/docs(云服务器运行的换成你的公网ip就好)

2.然后是前端,前端就很简单了

!pip install memobase  openai
from rich import print
from memobase import MemoBaseClient, ChatBlob

PROJECT_URL = "http://xxxxx:8019"
PROJECT_TOKEN = "secret"

client = MemoBaseClient(
    project_url=PROJECT_URL,
    api_key=PROJECT_TOKEN,
)

assert client.ping(), "Your Memobase server is not running"

messages = [
    {
        "role": "user",
        "content": "Hello, I'm Gus",
        "created_at&

你可能感兴趣的:(大模型实战应用,状态模式,人工智能,python)