diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 13566b81b018ad684f3a35fee301741b2734c8f4..0000000000000000000000000000000000000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
deleted file mode 100644
index 1c10e0efcc6a3e286a37391a07f85fd2208b228a..0000000000000000000000000000000000000000
--- a/.idea/dataSources.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
- sqlite.xerial
- true
- org.sqlite.JDBC
- jdbc:sqlite:$PROJECT_DIR$/00-chartgpt/chainlit/.chainlit/.langchain.db
- $ProjectFileDir$
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c24a62e0742e303a9f13d141bc30aac94d4ce271
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/00-chartgpt/chainlit/azure_demo.py b/00-chartgpt/chainlit/azure_demo.py
index 037cacb1d85da9cc05c1c9db6978b2a90ac2cee0..f84696c4e5eda48c2a53ce006c9292694fb3c04e 100644
--- a/00-chartgpt/chainlit/azure_demo.py
+++ b/00-chartgpt/chainlit/azure_demo.py
@@ -1,6 +1,5 @@
import os
import chainlit as cl
-
from langchain.chat_models import ChatOpenAI
from langchain.schema import (
HumanMessage,
@@ -12,21 +11,14 @@ os.environ["OPENAI_API_KEY"] = '70846324f01c4e5cb3cc11da28a1e091'
os.environ["OPENAI_API_BASE"] = 'https://opencatgpt.openai.azure.com/'
os.environ["OPENAI_API_TYPE"] = 'azure'
os.environ["OPENAI_API_VERSION"] = '2023-05-15'
-
chat = ChatOpenAI(model_name="gpt-35-turbo", engine="gpt-35-turbo")
history = [SystemMessage(content="你是一个聊天机器人,请回答下列问题。\n")]
-@cl.on_message # this function will be called every time a user inputs a message in the UI
+@cl.on_message
async def main(message: str):
- # history = [SystemMessage(content="你是一个聊天机器人,请回答下列问题。\n")]
history.append(HumanMessage(content=message))
res = await cl.make_async(sync_func)()
- # res = chat(history)
- # print(res.content)
- # this is an intermediate step
- # await cl.Message(author="Tool 1", content=f"Response from tool1", indent=1).send()
- # send back the final answer
history.append(res)
await cl.Message(content=f"{res.content}").send()
diff --git a/00-chartgpt/chainlit/mysql_azure_demo.py b/00-chartgpt/chainlit/mysql_azure_demo.py
new file mode 100644
index 0000000000000000000000000000000000000000..04d890987a4cea6ce67618eb1c321901211952d6
--- /dev/null
+++ b/00-chartgpt/chainlit/mysql_azure_demo.py
@@ -0,0 +1,50 @@
+import os
+import chainlit as cl
+from pymysql import Connection
+from langchain.chat_models import ChatOpenAI
+from langchain.schema import (
+ HumanMessage,
+ SystemMessage
+)
+
+# 构建到MySQL数据库的链接
+conn = Connection(
+ host="localhost", # 主机名(IP)
+ port=3306, # 端口
+ user="root", # 账户
+ password="123456", # 密码
+ autocommit=True # 自动提交(确认)
+)
+
+# 公司的key
+os.environ["OPENAI_API_KEY"] = '70846324f01c4e5cb3cc11da28a1e091'
+os.environ["OPENAI_API_BASE"] = 'https://opencatgpt.openai.azure.com/'
+os.environ["OPENAI_API_TYPE"] = 'azure'
+os.environ["OPENAI_API_VERSION"] = '2023-05-15'
+chat = ChatOpenAI(model_name="gpt-35-turbo", engine="gpt-35-turbo")
+history = [SystemMessage(content="你是一个聊天机器人,请回答下列问题。\n")]
+
+
+@cl.on_message
+async def main(message: str):
+ history.append(HumanMessage(content=message))
+ res = await cl.make_async(sync_func)()
+ insert(message, res)
+ history.append(res)
+ await cl.Message(content=f"{res.content}").send()
+
+
+def sync_func():
+ return chat(history)
+
+
+def insert(que, res):
+ cursor = conn.cursor() # 获取到游标对象
+ # 选择数据库
+ conn.select_db("kwan")
+ # 执行sql
+ cursor.execute("insert into chatbot(question,response) values(que, res)")
+ # # 通过commit确认
+ # conn.commit()
+ # 关闭链接
+ conn.close()
diff --git a/00-chartgpt/chainlit/test_app.py b/00-chartgpt/chainlit/test_app.py
index 1b309d8a8cc0797404a03585569818a00e7c8196..0d3795d30155fe0d7461eeeb3d095a3aa006ef26 100644
--- a/00-chartgpt/chainlit/test_app.py
+++ b/00-chartgpt/chainlit/test_app.py
@@ -1,7 +1,7 @@
import openai
import chainlit as cl
-openai.proxy = 'http://127.0.0.1:8088'
+openai.proxy = 'http://127.0.0.1:7890'
openai.api_key = "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"
model_name = "gpt-3.5-turbo"
settings = {
diff --git "a/14_\345\210\267\351\242\230/02-\351\223\276\350\241\250/problem_solving_01.py" "b/14_\345\210\267\351\242\230/02-\351\223\276\350\241\250/problem_solving_01.py"
index 5f428ae8b94c870cc21f8c35f0c86e60abb1bec0..5b1649d6b9b712cb33962efc6ee5b927f13fa8dc 100644
--- "a/14_\345\210\267\351\242\230/02-\351\223\276\350\241\250/problem_solving_01.py"
+++ "b/14_\345\210\267\351\242\230/02-\351\223\276\350\241\250/problem_solving_01.py"
@@ -38,13 +38,18 @@ class Solution:
if __name__ == '__main__':
- l1 = ListNode(2)
- l1.next = ListNode(4)
- l1.next.next = ListNode(3)
+ l1 = ListNode(9)
+ l1.next = ListNode(9)
+ l1.next.next = ListNode(9)
+ l1.next.next.next = ListNode(9)
+ l1.next.next.next.next = ListNode(9)
+ l1.next.next.next.next.next = ListNode(9)
+ l1.next.next.next.next.next.next = ListNode(9)
- l2 = ListNode(5)
- l2.next = ListNode(6)
- l2.next.next = ListNode(4)
+ l2 = ListNode(9)
+ l2.next = ListNode(9)
+ l2.next.next = ListNode(9)
+ l2.next.next.next = ListNode(9)
result = Solution().addTwoNumbers(l1, l2)
while result:
print(result.val, end=' -> ')