Ai开源项目链接

sqlchat:

https://github.com/sqlchat/sqlchat/blob/main/README.zh-CN.md

Chat2DB

https://github.com/alibaba/Chat2DB

const axios = require('axios');
const fs = require('fs');
require('dotenv').config();

// openai
// const API_URL = "https://api.openai.com/v1/chat/completions"
// customer
const API_URL = "https://api.xxx.com/v1/chat/completions"

// api key
const apiKey = process.env.OPENAI_API_KEY

const config = {
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${apiKey}`
  }
};

const params = {
  "model": "gpt-3.5-turbo", // "gpt-4"
  "messages": [
    {
      "role": "system",
      "content": "You are ChatGPT, a large language model trained by OpenAI.\nCarefully heed the user's instructions. \nRespond using Markdown."
    },
    {
      "role": "user", 
      "content": "在数据结构中,什么是链表数据结构?请用简洁的JavaScript代码来描述下这种数据,同时写下运行使用的代码,并说下这种数据结构的应用场景"
    }
  ],
  "temperature": 0.7
}

axios
  .post(API_URL, params, config)
  .then((res) => {
    console.log(res.data);
    const result = res.data.choices[0].message || {}; // { role: 'assistant', content: "" }
    console.log(result.content);
    fs.writeFileSync("data.md", result.content, (err) => {
      if (err) throw err;
    })
  })
  .catch((error) => {
    console.log(error);
  })

https://mp.weixin.qq.com/s/k-OF_L-x85B6H73xMoxpcg

搭建本地模型https://mp.weixin.qq.com/s/icF720E6wXrKXyByQkz-lw

Transformer

ChatGPT 在做什么… 以及它为何发挥作用?

https://mp.weixin.qq.com/s/p9xbzeFzI9OQ_JBEOweO2g

Transformer 框架论文作者:AI行业被困在了六七年前的原型上

https://mp.weixin.qq.com/s/qRTGTNbPDhp5ADRt9nlozA

https://zhuanlan.zhihu.com/p/403323731

https://cvmart.net/community/detail/4032

https://www.cnblogs.com/chenhuabin/p/16453665.html

https://mp.weixin.qq.com/s/V4vP2HUaB-LP88VdZkfNNw

import React, { useState, useEffect } from 'react';

// 解析 EventStream 数据的工具函数
const parseStreamData = (text) => {
  const jsonObjects = text
    .split('\n') // 按行分割
    .filter((line) => line.startsWith('data:') && line !== 'data: [DONE]') // 忽略 [DONE]
    .map((line) => line.replace('data:', '').trim()); // 去掉 'data:' 并修剪空格

  return jsonObjects.map((jsonString) => {
    try {
      return JSON.parse(jsonString); // 尝试解析 JSON
    } catch (e) {
      console.error('Error parsing JSON:', e);
      return null;
    }
  }).filter((obj) => obj !== null); // 过滤掉无效的 JSON 对象
};

const ChatComponent = () => {
  const [inputValue, setInputValue] = useState('');
  const [messages, setMessages] = useState([]);
  const [currentAssistantMessage, setCurrentAssistantMessage] = useState(''); // 管理当前助手消息

  const handleInputChange = (e) => {
    setInputValue(e.target.value);
  };

  const sendRequest = () => {
    const newUserMessage = { role: 'user', content: inputValue };

    // 将用户输入内容立即添加到消息列表
    setMessages((prevMessages) => [...prevMessages, newUserMessage]);

    fetch('https://api.moonshot.cn/v1/chat/completions', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer sk-xxx', // 替换成你的密钥
      },
      body: JSON.stringify({
        model: 'moonshot-v1-8k',
        messages: [...messages, newUserMessage], // 发送所有历史消息
        temperature: 0.3,
        stream: true
      }),
    })
      .then((response) => {
        if (!response.body) {
          throw new Error('No response body');
        }

        const reader = response.body.getReader(); // 获取流式读取器
        const decoder = new TextDecoder(); // 用于解码文本

        const readStream = () => {
          reader.read().then(({ done, value }) => {
            if (done) {
              return;
            }

            const text = decoder.decode(value); // 解码文本
            const jsonObjects = parseStreamData(text); // 解析所有有效的 JSON 对象

            jsonObjects.forEach((data) => {
              const content = data.choices[0].delta.content || ''; // 获取增量内容
              if (content) {
                setCurrentAssistantMessage((prev) => prev + content); // 累积助手消息
                setMessages((prevMessages) => {
                  const lastMessage = prevMessages[prevMessages.length - 1]; // 获取最后一条消息
                  if (lastMessage.role === 'assistant') {
                    lastMessage.content += content; // 更新助手消息
                    return [...prevMessages]; // 返回更新后的数组
                  } else {
                    return [...prevMessages, { role: 'assistant', content }]; // 添加新助手消息
                  }
                });
              }
            });

            readStream(); // 继续读取流
          });
        };

        readStream(); // 开始读取流
      })
      .catch((error) => {
        console.error('Error in POST request:', error);
      });

    setInputValue(''); // 清空输入框
  };

  return (
    <div>
      <div>
        <h2>Chat Conversation:</h2>
        <ul>
          {messages.map((msg, index) => (
            <li key={index}>
              <strong>{msg.role}:</strong> {msg.content} 
            </li> // 渲染每条消息
          ))}
        </ul>
      </div>

      <div>
        <input
          type="text"
          value={inputValue}
          onChange={handleInputChange}
          placeholder="Type your message here"
        />
        <button onClick={sendRequest}>Send</button> 
      </div>
    </div>
  );
};

export default ChatComponent;

问题1

几位同学假期组成一个小组去某市旅游,该市有6座塔,它们的位置分别为A.B.C,D.E,F.

同学们自由行动一段时间后,每位同学都发现,自己在所在的位置只能看到位于A,B,C,D处的四座塔,而看不到位于E 和F 的塔.已知

(1)同学们的位置和塔的位置均视为同一平面上的点,且这些点彼此不重合;

(2) A,B,C, D,E,F 中任意3点不共线;

(3) 看不到塔的唯一可能就是视线被其它的塔所阻挡,例如,如果某位同学所在的位置P

和A,B共线,且A在线段PB上,那么该同学就看不到位于B 处的塔.

请问,这个旅游小组最多可能有多少名同学?

(A) 3 (B) 4 (C) 6 (D) 12

https://mp.weixin.qq.com/s/FAf9t4y7zwiz8ZsnWZiZ6A

https://mp.weixin.qq.com/s/KlL3KyB1YDffM39gcppI_g

Spring AI https://mp.weixin.qq.com/s/4vdBuTltAKhb6_Q22u4zfQ

https://mp.weixin.qq.com/s/Y4Z5q5UuV9PqTk776SXi-A https://mp.weixin.qq.com/s/fbrsqWwqIQeckGLoRbx4uA

https://mp.weixin.qq.com/s/zdJtr1QGfKOCOfbbO0ADEQ

https://mp.weixin.qq.com/s/jKlQs7v–D-gOdTlAKaxNg

谷歌浏览器ai

js sdk

https://juejin.cn/post/737249474557694774

vue hooks

https://mp.weixin.qq.com/s/7iNLwpm_PTSHfMreR2Hq5Q

前端面试

https://github.com/pro-collection/interview-question/issues

https://github.com/KEYIERYI/crawl-gzh

https://github.com/KEYIERYI/FengJueZi-DevProcess?tab=readme-ov-file

https://github.com/1c7/chinese-independent-developer/?tab=readme-ov-file

ollama

https://mp.weixin.qq.com/s/majDONtuAUzN2SAaYWxH1Q

领域模型相关链接:

领域驱动设计DDD从入门到代码实践:https://developer.aliyun.com/article/1234407

https://github.com/RedSpider1/yxj_backend

https://mp.weixin.qq.com/s/_RKh_Bn02u9BNUwhUyW8Kwhttps://mp.weixin.qq.com/s/jld2TzQ47BdMjugcWWZ97whttps://mp.weixin.qq.com/s/jld2TzQ47BdMjugcWWZ97w

https://mp.weixin.qq.com/s/BVw7rQz82SFHvTkmXMhjYQhttps://mp.weixin.qq.com/s/3UA6QRaoz2HoeLNqqZosLQ

https://mp.weixin.qq.com/s/3UA6QRaoz2HoeLNqqZosLQ

上一篇
下一篇