Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
python-demo
提交
b3fe58c1
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看板
提交
b3fe58c1
编写于
6月 25, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:两个数组的交集
上级
b26175ca
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
67 addition
and
9 deletion
+67
-9
00-chartgpt/chainlit/nohup.out
00-chartgpt/chainlit/nohup.out
+4
-0
00-chartgpt/chainlit/test_01.py
00-chartgpt/chainlit/test_01.py
+3
-5
00-chartgpt/chainlit/test_app.py
00-chartgpt/chainlit/test_app.py
+6
-4
00-chartgpt/chainlit/test_app_01.py
00-chartgpt/chainlit/test_app_01.py
+3
-0
14_刷题/day03/problem_solving_19_01.py
14_刷题/day03/problem_solving_19_01.py
+15
-0
14_刷题/day03/problem_solving_19_02.py
14_刷题/day03/problem_solving_19_02.py
+17
-0
14_刷题/day03/problem_solving_19_03.py
14_刷题/day03/problem_solving_19_03.py
+19
-0
未找到文件。
00-chartgpt/chainlit/nohup.out
浏览文件 @
b3fe58c1
2023-06-25 11:27:36 - WARNING! engine is not default parameter.
engine was transferred to model_kwargs.
Please confirm that engine is what you intended.
2023-06-25 11:27:36 - Your app is available at http://localhost:8000
00-chartgpt/chainlit/test_01.py
浏览文件 @
b3fe58c1
...
...
@@ -2,11 +2,10 @@ import os
from
langchain
import
PromptTemplate
,
OpenAI
,
LLMChain
import
chainlit
as
cl
# os.environ["OPENAI_API_KEY"] = "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
"
os
.
environ
[
"
OPENAI_API_KEY"
]
=
"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
"
os
.
environ
[
"http_proxy"
]
=
"http://localhost:7890
"
os
.
environ
[
"
https_proxy"
]
=
"http://localhost:7890
"
os
.
environ
[
"OPENAI_API_KEY"
]
=
"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"
template
=
"""Question: {question}
Answer: Let's think step by step."""
...
...
@@ -14,5 +13,4 @@ Answer: Let's think step by step."""
def
factory
():
prompt
=
PromptTemplate
(
template
=
template
,
input_variables
=
[
"question"
])
llm_chain
=
LLMChain
(
prompt
=
prompt
,
llm
=
OpenAI
(
temperature
=
0
),
verbose
=
True
)
return
llm_chain
00-chartgpt/chainlit/test_app.py
浏览文件 @
b3fe58c1
import
openai
import
chainlit
as
cl
openai
.
api_key
=
"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"
openai
.
proxy
=
'http://127.0.0.1:7890'
# 道英
# openai.api_key = "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"
# 我的key
openai
.
api_key
=
"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"
# model_name = "text-davinci-003"
model_name
=
"gpt-3.5-turbo"
settings
=
{
...
...
@@ -25,14 +30,11 @@ def start_chat():
async
def
main
(
message
:
str
):
message_history
=
cl
.
user_session
.
get
(
"message_history"
)
message_history
.
append
({
"role"
:
"user"
,
"content"
:
message
})
msg
=
cl
.
Message
(
content
=
""
)
async
for
stream_resp
in
await
openai
.
ChatCompletion
.
acreate
(
model
=
model_name
,
messages
=
message_history
,
stream
=
True
,
**
settings
):
token
=
stream_resp
.
choices
[
0
][
"delta"
].
get
(
"content"
,
""
)
await
msg
.
stream_token
(
token
)
message_history
.
append
({
"role"
:
"assistant"
,
"content"
:
msg
.
content
})
await
msg
.
send
()
00-chartgpt/chainlit/test_app_01.py
浏览文件 @
b3fe58c1
import
openai
import
chainlit
as
cl
openai
.
proxy
=
'http://127.0.0.1:7890'
openai
.
api_key
=
"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"
model_name
=
"text-davinci-003"
settings
=
{
...
...
@@ -11,6 +13,7 @@ settings = {
"presence_penalty"
:
0
,
"stop"
:
[
"```"
],
}
prompt
=
"""Answer the following question:
{question}
"""
...
...
14_刷题/day03/problem_solving_19_01.py
0 → 100644
浏览文件 @
b3fe58c1
"""
两个数组的交集
给定两个数组 nums1 和 nums2 ,返回 它们的交集 。输出结果中的每个元素一定是 唯一 的。我们可以 不考虑输出结果的顺序 。
"""
from
typing
import
List
class
Solution
:
def
intersection
(
self
,
nums1
:
List
[
int
],
nums2
:
List
[
int
])
->
List
[
int
]:
return
list
(
set
(
nums1
).
intersection
(
nums2
))
if
__name__
==
'__main__'
:
result
=
Solution
().
intersection
([
1
,
2
,
2
,
1
],
[
2
,
2
])
print
(
result
)
14_刷题/day03/problem_solving_19_02.py
0 → 100644
浏览文件 @
b3fe58c1
"""
两个数组的交集
给定两个数组 nums1 和 nums2 ,返回 它们的交集 。输出结果中的每个元素一定是 唯一 的。我们可以 不考虑输出结果的顺序 。
"""
from
typing
import
List
class
Solution
:
def
intersection
(
self
,
nums1
:
List
[
int
],
nums2
:
List
[
int
])
->
List
[
int
]:
list1
=
set
(
nums1
)
list2
=
set
(
nums2
)
return
list
(
list1
&
list2
)
if
__name__
==
'__main__'
:
result
=
Solution
().
intersection
([
1
,
2
,
2
,
1
],
[
2
,
2
])
print
(
result
)
14_刷题/day03/problem_solving_19_03.py
0 → 100644
浏览文件 @
b3fe58c1
"""
两个数组的交集
给定两个数组 nums1 和 nums2 ,返回 它们的交集 。输出结果中的每个元素一定是 唯一 的。我们可以 不考虑输出结果的顺序 。
"""
from
typing
import
List
class
Solution
:
def
intersection
(
self
,
nums1
:
List
[
int
],
nums2
:
List
[
int
])
->
List
[
int
]:
result
=
[]
for
i
in
nums1
:
if
i
in
nums2
and
i
not
in
result
:
result
.
append
(
i
)
return
result
if
__name__
==
'__main__'
:
result
=
Solution
().
intersection
([
1
,
2
,
2
,
1
],
[
2
,
2
])
print
(
result
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录