Spaces:
No application file
No application file
BinZhang
commited on
Commit
·
8e0523e
1
Parent(s):
e7877ad
dftmsg
Browse files- app.py +22 -8
- b.py +0 -22
- requirements.txt +0 -5
app.py
CHANGED
@@ -1,17 +1,31 @@
|
|
|
|
1 |
from openai import OpenAI
|
2 |
|
|
|
3 |
base_url = "https://internlm-chat.intern-ai.org.cn/puyu/api/v1/"
|
4 |
-
|
|
|
5 |
|
|
|
6 |
client = OpenAI(
|
7 |
-
api_key=api_key
|
8 |
base_url=base_url,
|
9 |
)
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
1 |
+
import streamlit as st
|
2 |
from openai import OpenAI
|
3 |
|
4 |
+
# 设置 API 参数
|
5 |
base_url = "https://internlm-chat.intern-ai.org.cn/puyu/api/v1/"
|
6 |
+
api_key = "sk-请填写准确的 token!"
|
7 |
+
model = "internlm2.5-latest"
|
8 |
|
9 |
+
# 创建 OpenAI 客户端
|
10 |
client = OpenAI(
|
11 |
+
api_key=api_key,
|
12 |
base_url=base_url,
|
13 |
)
|
14 |
|
15 |
+
# 设置页面标题
|
16 |
+
st.title("Chat with InternLM")
|
17 |
+
|
18 |
+
# 创建一个文本输入框供用户输入问题
|
19 |
+
user_input = st.text_input("请输入你的问题:")
|
20 |
+
|
21 |
+
# 按钮用于提交问题
|
22 |
+
if st.button("发送"):
|
23 |
+
# 调用 OpenAI API 获取回复
|
24 |
+
chat_rsp = client.chat.completions.create(
|
25 |
+
model=model,
|
26 |
+
messages=[{"role": "user", "content": user_input}],
|
27 |
+
)
|
28 |
|
29 |
+
# 显示回复
|
30 |
+
for choice in chat_rsp.choices:
|
31 |
+
st.write(f"回复: {choice.message.content}")
|
b.py
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
from openai import OpenAI
|
2 |
-
|
3 |
-
base_url = "https://internlm-chat.intern-ai.org.cn/puyu/api/v1/"
|
4 |
-
api_key = "sk-请填写准确的 token!"
|
5 |
-
model="internlm2.5-latest"
|
6 |
-
|
7 |
-
# base_url = "https://api.siliconflow.cn/v1"
|
8 |
-
# api_key = "sk-请填写准确的 token!"
|
9 |
-
# model="internlm/internlm2_5-7b-chat"
|
10 |
-
|
11 |
-
client = OpenAI(
|
12 |
-
api_key=api_key ,
|
13 |
-
base_url=base_url,
|
14 |
-
)
|
15 |
-
|
16 |
-
chat_rsp = client.chat.completions.create(
|
17 |
-
model=model,
|
18 |
-
messages=[{"role": "user", "content": "xtuner是什么?"}],
|
19 |
-
)
|
20 |
-
|
21 |
-
for choice in chat_rsp.choices:
|
22 |
-
print(choice.message.content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
llama-index==0.11.20
|
2 |
-
llama-index-llms-replicate==0.3.0
|
3 |
-
llama-index-llms-openai-like==0.2.0
|
4 |
-
llama-index-embeddings-huggingface==0.3.1
|
5 |
-
llama-index-embeddings-instructor==0.2.1
|
|
|
|
|
|
|
|
|
|
|
|