微信扫码
与创始人交个朋友
我要投稿
问题1:git克隆失败-文件名太长答案1:查看错误信息中是否包含关键字:Filename too long问题2:git克隆失败-access_token失效答案2:查看错误信息中是否包含关键字:Authentication failed for、 Access denied、invalid_token。解决方法:重新生成一个有效的access_toekn问题3:git克隆失败-网络超时答案3:查看错误信息中是否包含关键字:Connection timed out、Unknown error、Could not resolve host等。可能是执行机与yfgitlab网络不通或者网络波动导致,执行机dns配置有问题,不能访问yfgitlab的域名问题4:git克隆失败-CI站点上配置的工程信息异常答案4:查看错误信息中是否包含关键字:FETCH_HEAD error: Sparse checkout leaves no entry on working directory。可能原因:1)、工程信息中填写的脚本路径斜杠反了,比如不正确的写法:TEST\Stability\ITC,正确的写法:TEST/Stability/ITC;2)多个脚本路径用英文分号拼接,不能使用其他符号,比如TEST/PI/SD,TEST/PI/COMMON使用逗号拼接的是异常的问题5:git克隆失败-‘git’ 不是内部或外部命令,也不是可运行的程序答案5:1、检查下执行机上是否安装了git;2、可能链接jenkins的时候没有安装git,链接成功后才安装的git,联系工厂客服删除节点,用户重新部署执行机。问题6:git克隆失败-分支名中带有.号答案6:查看错误信息中是否包含关键字:Invalid argument Cloning into 。换一个没有.号的分支名问题7:git克隆失败-git链接不是以.git结尾答案7:查看错误信息中是否包含关键字:没有找到项目名称(xxx)对应的项目id。需要填写完整的git地址问题8:git克隆失败-out of memory答案8:查看错误信息中是否包含关键字:out of memory、No space left on device。用户需要检查下执行机硬盘空间
# coding=utf-8
from langchain_community.document_loaders import TextLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.embeddings importHuggingFaceEmbeddings
from langchain_community.vectorstores import Chroma
from langchain_community.llms import Ollama
from langchain.chains import RetrievalQA
# 导入文本
loader = TextLoader(r"D:\vec\document\test.txt")
# 将文本转成 Document 对象
data = loader.load()
print(f'documents:{len(data)}')
# 初始化加载器
text_splitter = RecursiveCharacterTextSplitter(chunk_size=100, chunk_overlap=0)
# 切割加载的 document
split_docs = text_splitter.split_documents(data)
print("split_docs size:",len(split_docs))
model_name = r"D:\vec\bce-embedding-vase_v1"
model_kwargs = {'device': 'cpu'}
encode_kwargs = {'normalize_embeddings': False}
embeddings = HuggingFaceEmbeddings(
model_name=model_name,
model_kwargs=model_kwargs,
encode_kwargs=encode_kwargs
)
# 保存向量数据库部分
# 初始化数据库
db = Chroma.from_documents(split_docs, embeddings, persist_directory=r"D:\vec\vecdb")
# 持久化
db.persist()
# 对数据进行加载
db = Chroma(persist_directory=r"D:\vec\vecdb", embedding_function=embeddings)
question = "out of memory"
# 测试寻找四个相似的样本
similarDocs = db.similarity_search(question,k=4)
# coding=utf-8
from langchain_community.document_loaders import TextLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.embeddings importHuggingFaceEmbeddings
from langchain_community.vectorstores import Chroma
from langchain_community.llms import Ollama
from langchain.chains import RetrievalQA
retriever = db.as_retriever()
qa = RetrievalQA.from_chain_type(llm=Ollama(base_url='http://XX.XX.XX.XXX:9999',model="Qwen2-7b:latest"),retriever=retriever)
query = "我在做持续集成的时候,发现在git克隆的时候出现out of memory"
print(qa.run(query))
from flask import Flask, request, jsonify
from flask_cors import CORS
# 上面的代码保持不变
from langchain_community.document_loaders import TextLoader
from langchain_huggingface import HuggingFaceEmbeddings
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import Chroma
from langchain_community.llms import Ollama
from langchain.chains import RetrievalQA
# 导入文本
loader = TextLoader(r"D:\vec\document\test.txt")
data = loader.load()
print(f'documents:{len(data)}')
text_splitter = RecursiveCharacterTextSplitter(chunk_size=100, chunk_overlap=0)
split_docs = text_splitter.split_documents(data)
print("split_docs size:", len(split_docs))
model_name = r"D:\vec\bce-embedding-vase_v1"
model_kwargs = {'device': 'cpu'}
encode_kwargs = {'normalize_embeddings': False}
embeddings = HuggingFaceEmbeddings(
model_name=model_name,
model_kwargs=model_kwargs,
encode_kwargs=encode_kwargs
)
db = Chroma.from_documents(split_docs, embeddings, persist_directory=r"D:\vec\vecdb")
db.persist()
db = Chroma(persist_directory=r"D:\vec\vecdb", embedding_function=embeddings)
retriever = db.as_retriever()
qa = RetrievalQA.from_chain_type(llm=Ollama(base_url='http://xx.xx.xxx.xxx:9999', model="Qwen2-7b:latest"), retriever=retriever)
# 创建FastAPI应用
app =Flask(__name__)
CORS(app)
async def query_endpoint():
# 使用qa.run处理请求中的查询
data = request.get_json()
messages = data.get('query')
result = qa.run(messages)
return jsonify({"response": result})
if __name__ == '__main__':
app.run(debug=True)
● 前端交互代码如下
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chat Interface with Markdown</title>
<style>
#chatHistory {
height: 800px;
overflow-y: scroll;
border: 1px solid #ccc;
padding: 10px;
}
#userInput {
width: 100%;
box-sizing: border-box;
margin-bottom: 10px;
}
</style>
<!-- 引入marked库 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.2.12/marked.min.js"></script>
</head>
<body>
<div id="chatHistory"></div>
<input type="text" id="userInput" placeholder="请输入你的问题...">
<button onclick="sendMessage()">发送</button>
<script>
function sendMessage() {
const userInput = document.getElementById('userInput');
const chatHistory = document.getElementById('chatHistory');
// 获取用户输入并清空输入框
const userMessage = userInput.value;
userInput.value = '';
// 构建请求体
const data = {
"query": userMessage
};
// 发送POST请求到后端接口
fetch('http://127.0.0.1:5000/query', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
// 假设后端返回的数据格式为 { "response": "回答内容" }
const botResponse = data.response;
// 在聊天历史中添加用户的问题
chatHistory.innerHTML += `<p><strong>你:</strong> ${userMessage}</p>`;
// 将Markdown转换为HTML并添加机器人的回答
if (botResponse) {
const htmlResponse = marked.parse(botResponse);
chatHistory.innerHTML += `<p><strong>机器人:</strong> ${htmlResponse}</p>`;
} else {
console.error("没有从后端接收到有效的回答");
}
// 滚动到底部以便查看最新消息
chatHistory.scrollTop = chatHistory.scrollHeight;
})
.catch(error => {
console.error('Error:', error);
// 可以在这里添加错误信息的展示逻辑
chatHistory.innerHTML += `<p><strong>错误:</strong> 发生了一个错误,请稍后再试。</p>`;
});
}
</script>
</body>
</html>
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-05-08
2024-07-22
2024-07-14
2024-06-30
2024-07-11
2024-03-31
2024-08-09
2024-11-08
2024-10-16
2024-07-14