Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
python-demo
提交
bb7e548f
P
python-demo
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
python-demo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
python-demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
bb7e548f
编写于
7月 02, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:添加mysql
上级
9711c0b3
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
82 addition
and
36 deletion
+82
-36
.idea/.gitignore
.idea/.gitignore
+0
-8
.idea/dataSources.xml
.idea/dataSources.xml
+0
-12
.idea/inspectionProfiles/Project_Default.xml
.idea/inspectionProfiles/Project_Default.xml
+19
-0
00-chartgpt/chainlit/azure_demo.py
00-chartgpt/chainlit/azure_demo.py
+1
-9
00-chartgpt/chainlit/mysql_azure_demo.py
00-chartgpt/chainlit/mysql_azure_demo.py
+50
-0
00-chartgpt/chainlit/test_app.py
00-chartgpt/chainlit/test_app.py
+1
-1
14_刷题/02-链表/problem_solving_01.py
14_刷题/02-链表/problem_solving_01.py
+11
-6
未找到文件。
.idea/.gitignore
已删除
100644 → 0
浏览文件 @
9711c0b3
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
.idea/dataSources.xml
已删除
100644 → 0
浏览文件 @
9711c0b3
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"DataSourceManagerImpl"
format=
"xml"
multifile-model=
"true"
>
<data-source
source=
"LOCAL"
name=
".langchain"
uuid=
"6ed2f640-6bd4-426b-bab0-933c1e5074e0"
>
<driver-ref>
sqlite.xerial
</driver-ref>
<synchronize>
true
</synchronize>
<jdbc-driver>
org.sqlite.JDBC
</jdbc-driver>
<jdbc-url>
jdbc:sqlite:$PROJECT_DIR$/00-chartgpt/chainlit/.chainlit/.langchain.db
</jdbc-url>
<working-dir>
$ProjectFileDir$
</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
.idea/inspectionProfiles/Project_Default.xml
0 → 100644
浏览文件 @
bb7e548f
<component
name=
"InspectionProjectProfileManager"
>
<profile
version=
"1.0"
>
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"PyPep8NamingInspection"
enabled=
"true"
level=
"WEAK WARNING"
enabled_by_default=
"true"
>
<option
name=
"ignoredErrors"
>
<list>
<option
value=
"N802"
/>
</list>
</option>
</inspection_tool>
<inspection_tool
class=
"PyUnresolvedReferencesInspection"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"ignoredIdentifiers"
>
<list>
<option
value=
"socketio.*"
/>
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
00-chartgpt/chainlit/azure_demo.py
浏览文件 @
bb7e548f
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
()
...
...
00-chartgpt/chainlit/mysql_azure_demo.py
0 → 100644
浏览文件 @
bb7e548f
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
()
00-chartgpt/chainlit/test_app.py
浏览文件 @
bb7e548f
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
=
{
...
...
14_刷题/02-链表/problem_solving_01.py
浏览文件 @
bb7e548f
...
...
@@ -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
=
' -> '
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录