大家好,我 是AI 的魔盒,让我们一起探索AI的魔力,我会持续将最新大模型的资讯,大模型的实践与大家分享,请持续关注!
一、首先需要安装Ollama,安装ollama的方法请参考我前边的文档
【在 Windows 系统下,用 DeepSeek R3 + Dify搭建私有知识库的超详细教程】_windows dify deepseek-CSDN博客
二、使用ollama安装QwQ-32B
安装命令如下:
ollama run qwq
下载速度咋也太快了吧

好事多磨啊,正在期盼的时候,突然报如下错误:
C:\Users\Administrator>ollama run qwq pulling manifest pulling manifest pulling c62ccde5630c... 0% ▕ ▏ 999 KB/ 19 GB Error: max retries exceeded: write C:\Users\Administrator\.ollama\models\blobs\sha256-c62ccde5630c20c8a9cf601861d31977d07450cad6dfdf1c661aab307107bddb-partial: There is not enough space on the disk.
解决方法
设置ollama_models目录位置

OLLAMA_MODELS=E:\ai\models
设置完成后使用如下命令查看是否已经生效
ollama serve

C:\Users\Administrator>ollama serve 2025/03/07 14:52:30 routes.go:1187: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://127.0.0.1:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_KV_CACHE_TYPE: OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:D:\\ai\\models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://* vscode-webview://*] OLLAMA_SCHED_SPREAD:false ROCR_VISIBLE_DEVICES:]" time=2025-03-07T14:52:31.631+08:00 level=INFO source=images.go:432 msg="total blobs: 12" time=2025-03-07T14:52:31.632+08:00 level=INFO source=images.go:439 msg="total unused blobs removed: 0" time=2025-03-07T14:52:31.632+08:00 level=INFO source=routes.go:1238 msg="Listening on 127.0.0.1:11434 (version 0.5.7)" time=2025-03-07T14:52:31.633+08:00 level=INFO source=routes.go:1267 msg="Dynamic LLM libraries" runners="[cpu_avx2 cuda_v11_avx cuda_v12_avx rocm_avx cpu cpu_avx]" time=2025-03-07T14:52:31.633+08:00 level=INFO source=gpu.go:226 msg="looking for compatible GPUs" time=2025-03-07T14:52:31.633+08:00 level=INFO source=gpu_windows.go:167 msg=packages count=1 time=2025-03-07T14:52:31.633+08:00 level=INFO source=gpu_windows.go:183 msg="efficiency cores detected" maxEfficiencyClass=1 time=2025-03-07T14:52:31.633+08:00 level=INFO source=gpu_windows.go:214 msg="" package=0 cores=14 efficiency=8 threads=20 time=2025-03-07T14:52:31.770+08:00 level=INFO source=types.go:131 msg="inference compute" id=GPU-f7eb66b9-7d88-dcbb-dc72-62d2ba3458c1 library=cuda variant=v12 compute=8.6 driver=12.8 name="NVIDIA GeForce RTX 3060" total="12.0 GiB" available="11.0 GiB"
接着跑,这次成功了,哈哈哈
C:\Users\Administrator>ollama run qwq pulling manifest pulling c62ccde5630c... 100% ▕█████████████████████████████████████████████████████████▏ 19 GB pulling 41190096a061... 100% ▕█████████████████████████████████████████████████████████▏ 1.2 KB pulling d18a5cc71b84... 100% ▕█████████████████████████████████████████████████████████▏ 11 KB pulling 4afe5edfdb51... 100% ▕█████████████████████████████████████████████████████████▏ 77 B pulling 6a8faa2fb8b0... 100% ▕█████████████████████████████████████████████████████████▏ 488 B verifying sha256 digest writing manifest success
终于看见了,整体一下来效果还不错,中文名叫通义千问,英文名叫Qwen

>>> 你好 <think> </think> 你好!今天过得怎么样? >>> 你是谁 <think> 嗯,用户问“你是谁”,我需要先回顾之前的对话。用户一开始打招呼“你好”,然后我回应了友好的问候,并询问他们的情况。现 在用户接着问“你是谁”,显然是想了解我的身份。 首先,我要确认用户的意图。可能他们刚接触这个平台,或者之前没和AI交流过,所以想知道对方是谁。这时候需要明确回答自己的 身份,同时保持友好和简洁。 根据之前的设定,我应该介绍自己是通义千问,阿里云研发的超大规模语言模型。要提到我的功能,比如回答问题、创作文字等,并 且强调能帮助用户解决问题或提供信息。这样既回答了问题,又展示了我能提供的服务,鼓励用户继续互动。 另外,要注意用户的使用场景可能是在测试AI的能力,或者真的需要帮助。所以回应里应该包含足够的信息,但不过于冗长。同时保 持口语化,避免技术术语太多,让用户容易理解。 还要考虑是否遗漏了什么。比如用户可能想知道我的能力范围,或者是否有特殊功能。可以简要提到多语言支持和不同领域的知识, 这样用户知道我可以处理各种主题的问题。 最后,确保语气友好,结尾用问句邀请用户提出具体需求,促进进一步的对话。检查有没有拼写或语法错误,保持回答自然流畅。 </think> 你好!我是通义千问,阿里巴巴集团旗下的超大规模语言模型。我的中文名叫通义千问,英文名叫Qwen,可以回答问题、创作文字, 比如写故事、写公文、写邮件、写剧本、逻辑推理、编程等等,还能表达观点,玩游戏等。有什么我可以帮你的吗?😊
>>> 帮我写一段java代码,框架用SpringCloud,实现用户登录,前端用vue <think> 嗯,用户让我帮忙写一段Java代码,使用Spring Cloud框架实现用户登录功能,前端用Vue。首先,我需要确认用户的具体需求是什么,可能他 们正在开发一个前后端分离的系统,需要后端提供登录接口,并且前端用Vue来展示。 首先考虑后端部分,Spring Cloud通常涉及微服务架构,但用户可能只需要基础的登录功能,暂时不需要复杂的分布式配置。所以应该先搭建 一个简单的Spring Boot项目作为后端,集成必要的安全机制,比如Spring Security或者JWT。 然后是数据库设计,用户表需要包含用户名、密码等字段。这里可能需要用到JPA或者MyBatis来操作数据库。考虑到简单性,使用Spring Data JPA会比较方便,自动处理CRUD操作。 接下来是登录逻辑,包括验证用户凭证,生成token(比如JWT),以及返回给前端。同时要确保密码加密存储和安全传输,所以需要配置 BCryptPasswordEncoder进行密码加密,并且在接口上添加正确的注解来控制访问权限。 前端部分用Vue的话,可能需要创建一个简单的表单页面,发送登录请求到后端API。这里需要注意的是跨域问题,在Spring Boot中要配置允许 的来源,比如使用@CrossOrigin或者CORS过滤器。 用户可能是开发新手,所以代码示例应该尽量简洁,注释清楚,并且涵盖关键步骤。同时需要提醒他们安装必要的依赖项,比如 spring-boot-starter-web、spring-security、jjwt等,并在pom.xml中添加相关依赖。 另外,可能还需要考虑异常处理和响应格式的统一,比如返回JSON结果包含token或错误信息。此外,前端Vue代码需要处理这些响应,并进行 路由跳转或者显示提示信息。 最后要检查是否有遗漏的部分,比如数据库配置、安全配置是否正确,以及前后端如何配合测试。可能用户在运行时会遇到问题,所以给出基 本的测试方法和注意事项也很重要。 </think> 好的!以下是一个简单的 Spring Cloud 后端(Spring Boot)+ Vue 前端实现用户登录功能的示例代码: --- ### **后端 (Spring Boot)** #### 1. 依赖配置(`pom.xml`) ```xml <dependencies> <!-- Spring Boot Web --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- Spring Security --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!-- JWT 依赖 --> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>0.11.5</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <version>0.11.5</version> </dependency> <!-- 数据库相关 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> </dependencies> ``` #### 2. 用户实体类(`User.java`) ```java import javax.persistence.Entity; import javax.persistence.Id; @Entity public class User { @Id private String username; private String password; // 构造函数、Getter 和 Setter 方法 public User() {} public User(String username, String password) { this.username = username; this.password = password; } // Getters and Setters... } ``` #### 3. 用户仓库接口(`UserRepository.java`) ```java import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository<User, String> { User findByUsername(String username); } ``` #### 4. 登录控制器(`AuthController.java`) ```java import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/auth") public class AuthController { @Autowired private UserRepository userRepository; // 登录接口 @PostMapping("/login") public String login(@RequestBody User user) { User existingUser = userRepository.findByUsername(user.getUsername()); if (existingUser != null && new BCryptPasswordEncoder().matches(user.getPassword(), existingUser.getPassword())) { // 生成 JWT Token(示例,需配置密钥) return Jwts.builder() .setSubject(existingUser.getUsername()) .signWith(SignatureAlgorithm.HS256, "your-secret-key") .compact(); } return "登录失败!"; } // 注册接口(可选) @PostMapping("/register") public String register(@RequestBody User user) { userRepository.save(user); return "注册成功!"; } } ``` #### 5. Spring Security 配置(`SecurityConfig.java`) ```java import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Bean public BCryptPasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable() .authorizeRequests() .antMatchers("/api/auth/**").permitAll() .anyRequest().authenticated(); } } ``` #### 6. 启动类(`Application.java`) ```java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` --- ### **前端 (Vue)** #### 1. 创建 Vue 登录表单(`Login.vue`) ```vue <template> <div> <h2>用户登录</h2> <input v-model="username" placeholder="用户名" /> <input type="password" v-model="password" placeholder="密码" /> <button @click="login">登录</button> <p>{{ message }}</p> </div> </template> <script> export default { data() { return { username: '', password: '', message: '' }; }, methods: { async login() { const response = await fetch('http://localhost:8080/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: this.username, password: this.password }) }); if (response.ok) { const token = await response.text(); localStorage.setItem('token', token); this.message = '登录成功!'; // 跳转到主页或其他页面 } else { this.message = '登录失败,请检查用户名或密码。'; } } } }; </script> ``` #### 2. 主文件(`main.js`) ```javascript import Vue from 'vue'; import Login from './components/Login.vue'; new Vue({ el: '#app', template: '<Login/>', components: { Login } }); ``` --- ### **运行步骤** 1. 启动 Spring Boot 应用。 2. 访问 `http://localhost:8080`(假设前端端口为默认)或配置的 Vue 地址。 --- ### **注意事项** - 需要配置数据库连接(示例使用 H2 内存数据库,生产环境建议替换为 MySQL 等)。 - JWT 密钥需保密且不可硬编码在代码中,可通过环境变量注入。 - 前端需处理 Token 的存储和验证(如拦截未授权请求)。