我正在使用 Python 的虚拟环境“venv”。我当前的版本是3.11.2
我需要将其降级。
我已经尝试过以下步骤:
pip3 install python==3.10.10
Run Code Online (Sandbox Code Playgroud)
并得到以下错误:
错误:找不到满足要求的版本 python==3.10.10 (来自版本:无)
错误:找不到 python==3.10.10 的匹配发行版
我也尝试过较低的版本,如 3.8.0、3.9.0,...总是同样的错误。
谢谢
我正在使用 Python Flask 应用程序进行数据聊天。因此,在控制台中,我可以直接从 OpenAI 获得流式响应,因为我可以使用 flag 启用流处理streaming=True。
问题是,我无法在 API 调用中 \xe2\x80\x9cforward\xe2\x80\x9d 流或 \xe2\x80\x9cshow\xe2\x80\x9d 流。
\n处理 OpenAI 和链的代码是:
\ndef askQuestion(self, collection_id, question):\n collection_name = "collection-" + str(collection_id)\n self.llm = ChatOpenAI(model_name=self.model_name, temperature=self.temperature, openai_api_key=os.environ.get('OPENAI_API_KEY'), streaming=True, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]))\n self.memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True, output_key='answer')\n \n chroma_Vectorstore = Chroma(collection_name=collection_name, embedding_function=self.embeddingsOpenAi, client=self.chroma_client)\n\n\n self.chain = ConversationalRetrievalChain.from_llm(self.llm, chroma_Vectorstore.as_retriever(similarity_search_with_score=True),\n return_source_documents=True,verbose=VERBOSE, \n memory=self.memory)\n \n\n result = self.chain({"question": question})\n \n res_dict = {\n "answer": result["answer"],\n }\n\n res_dict["source_documents"] = []\n\n for source in result["source_documents"]:\n res_dict["source_documents"].append({\n "page_content": source.page_content,\n "metadata": …Run Code Online (Sandbox Code Playgroud) 我想替换对象数组中的 \n 。现在我遇到了这个,但它只替换字符串,而不是实际的'\n',这会导致换行。
var obj = {
'a': '\nThe fooman poured the drinks.',
'b': {
'c': 'Dogs say fook, but what does the fox say?'
}
}
console.log(JSON.parse(JSON.stringify(obj).replace(/\n/g, '')));Run Code Online (Sandbox Code Playgroud)
谢谢大家