Docker三分钟搞定LLama3开源大模型本地部署 其他

概述

LLaMA-3(Large Language Model Meta AI 3)是由Meta公司开发的大型开源生成式人工智能模型。它在模型结构上与前一代LLaMA-2相比没有大的变动。

LLaMA-3模型分为不同规模的版本,包括小型、中型和大型,以适应不同的应用需求和计算资源。小型模型参数规模为8B,中型模型参数规模为70B,而大型模型则达到400B,仍在训练中,目标是实现多模态、多语言的功能,预计效果将与GPT 4/GPT 4V相当。

安装 Ollama

Ollama 是一个开源的大型语言模型(LLM)服务工具,它允许用户在本地机器上运行和部署大型语言模型。Ollama 设计为一个框架,旨在简化在 Docker 容器中部署和管理大型语言模型的过程,使得这一过程变得简单快捷。用户可以通过简单的命令行操作,快速在本地运行如 Llama 3 这样的开源大型语言模型。

官网地址:https://ollama.com/download

Ollama 支持多种平台,包括 Mac 和 Linux,并提供了 Docker 镜像以简化安装过程。用户可以通过编写 Modelfile 来导入和自定义更多的模型,这类似于 Dockerfile 的作用。Ollama 还具备一个 REST API,用于运行和管理模型,以及一个用于模型交互的命令行工具集。

Ollama服务启动日志

模型管理

下载模型

ollama pull llama3:8b

默认下载的是llama3:8b。这里冒号前面代表模型名称,冒号后面代表tag,可以从这里查看llama3的所有tag

模型测试

注意:如果想让模型中文回复,请先输入:你好!请中文回复

配置Open-WebUI

在CPU下运行

docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

输入地址 http://127.0.0.1:3000 进行访问

初次访问需要注册,这里我注册一个账号,注册完成登录成功

切换中文语言

下载llama3:8b模型

llama3:8b

下载完成

使用

选择模型

使用模型

注意:如果想让模型中文回复,请先输入:你好!请中文回复

内存

注:此文章转载自 Tinywan 开源技术小栈


杨佳乐 发布于  2024-4-30 15:11 

webman/push 统计在线人数 PHP

自定义进程定时获取在线人数广播给所有在线用户
process/Status.php

<?php

namespace process;

use app\Request;
use Webman\Push\Api;
use Workerman\Timer;
use Workerman\Worker;
use think\facade\Db;

class Status
{
    public function __construct()
    {
        Timer::add(3, function () {
            $this->status();
        });
    }

    public function status()
    {
        static $user_count = 0, $page_count = 0;
        $api = new Api(
            'http://127.0.0.1:3232',
            config('plugin.webman.push.app.app_key'),
            config('plugin.webman.push.app.app_secret')
        );
        $result = $api->get('/channels', ['filter_by_prefix' => 'user', 'info' => 'subscription_count']);
        if (!$result || $result['status'] != 200) {
            return;
        }
        $channels = $result['result']['channels'];
        $user_count_now = count($channels);
        $page_count_now = 0;
        foreach ($channels as $channel) {
            $page_count_now += $channel['subscription_count'];
        }
        if ($page_count_now == $page_count && $user_count_now === $user_count) {
            return;
        }
        $user_count = $user_count_now;
        $page_count = $page_count_now;

        $api->trigger('online-page', 'update_online_status', "当前<b>$user_count</b>人在线,共打开<b>$page_count</b>个页面");
    }
}

自定义进程配置文件
config/process.php

<?php
use Workerman\Worker;
return [
    // ...其它配置...

    'status'  => [
        'handler'  => process\Status::class
    ]
];

前端js代码

var connection = new Push({
    url: 'wss://xxx.com',
    app_key: 'xxxx',
});
function update_online_status(status) {
    $('#online_status').html(status);
}
var online_channel = connection.subscribe('online-page');
online_channel.on('update_online_status', update_online_status);
var user_channel = connection.subscribe('user-<?=session()->getId()?>');
user_channel.on('update_online_status', update_online_status);

以上是实现类似workerman站点底部实时在线统计的代码


杨佳乐 发布于  2024-4-30 14:13 

站点介绍

该博客站于2024-4-30全新升级,用于记录日常开发中遇到的问题,以及一些新闻热搜

个人承接PHP二次开发、网站定制、公众号小程序定制开发、网站源码搭建、服务器维护等业务

出租宝塔专业版账号,里面包含网站监控、nginx防火墙、网站防篡改等插件,长期租用价格优惠

联系微信:admin_1998
联系QQ:1401586744


杨佳乐 发布于  2024-4-30 11:57 

宝塔定时任务访问url url内有header跳转处理 服务器

使用宝塔计划任务访问url类型不会自动跳转,需要使用shell命令

wget --spider -nv --max-redirect 100000 "http://xxxxx"


杨佳乐 发布于  2024-4-30 11:23 

uniapp 封装request请求 前端

Vue.prototype.sendRequest = function(param,backpage, backtype){
    var _self = this, 
        url = param.url,
        method = param.method,
        header = {},
        data = param.data || {}, 
        token = "",
        hideLoading = param.hideLoading || false;

    //拼接完整请求地址
    var requestUrl = this.siteBaseUrl + url;
    //固定参数:仅仅在小程序绑定页面通过code获取token的接口默认传递了参数token = login
    if(!data.token){//其他业务接口传递过来的参数中无token
        token = uni.getStorageSync(this.sessionKey);//参数中无token时在本地缓存中获取
        console.log("当前token:" + token);
        if(!token){//本地无token需重新登录(退出时清缓存token)
            _self.login(backpage, backtype);
            return;
        }else{
            data.token = token;
        }
    }
    var timestamp = Date.parse(new Date());//时间戳
    data["timestamp"] = timestamp;
    // #ifdef MP-WEIXIN
    data["device"] = "wxapp";
    data["ver"] = "1.1.30";
    // #endif
    // #ifdef APP-PLUS || H5
    data["device"] = "iosapp";
    data["ver"] = "1.0.0";
    // #endif

    //请求方式:GET或POST(POST需配置header: {'content-type' : "application/x-www-form-urlencoded"},)
    if(method){
        method = method.toUpperCase();//小写改为大写
        if(method=="POST"){
            header = {'content-type' : "application/x-www-form-urlencoded"};
        }else{
            header = {'content-type' : "application/json"};
        }
    }else{
        method = "GET";
        header = {'content-type' : "application/json"};
    }
    //用户交互:加载圈
    if (!hideLoading) {
        uni.showLoading({title:'加载中...'});
    }

    console.log("网络请求start");
    //网络请求
    uni.request({
        url: requestUrl,
        method: method,
        header: header,
        data: data,
        success: res => {
            console.log("网络请求success:" + JSON.stringify(res));
            if (res.statusCode && res.statusCode != 200) {//api错误
                uni.showModal({
                    content:"" + res.errMsg
                });
                return;
            }
            if (res.data.code) {//返回结果码code判断:0成功,1错误,-1未登录(未绑定/失效/被解绑)
                if (res.data.code == "-1") {
                    _self.login(backpage, backtype);
                    return;
                }
                if (res.data.code != "0") {
                    uni.showModal({
                        showCancel:false,
                        content:"" + res.data.msg
                    });
                    return;
                }
            } else{
                uni.showModal({
                    showCancel:false,
                    content:"No ResultCode:" + res.data.msg
                });
                return;
            }
            typeof param.success == "function" && param.success(res.data);
        },
        fail: (e) => {
            console.log("网络请求fail:" + JSON.stringify(e));
            uni.showModal({
                content:"" + e.errMsg
            });
            typeof param.fail == "function" && param.fail(e.data);
        },
        complete: () => {
            console.log("网络请求complete");
            if (!hideLoading) {
                uni.hideLoading();
            }
            typeof param.complete == "function" && param.complete();
            return;
        }
    });
}

杨佳乐 发布于  2024-4-30 11:22