sq66 commited on
Commit
c052248
·
verified ·
1 Parent(s): beefbc4

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +112 -0
README.md ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # partyrock2api
2
+ 基于partyrock的转openAI服务,抱脸部署
3
+ ## 支持模型
4
+ - claude-3-5-haiku-20241022
5
+ - claude-3-5-sonnet-20241022
6
+ - nova-lite-v1-0
7
+ - nova-pro-v1-0
8
+ - llama3-1-7b
9
+ - llama3-1-70b
10
+ - mistral-small
11
+ - mistral-large
12
+
13
+ ## 请求格式
14
+ 已转换为OpenAI格式,支持非流与流式请求,支持temperature与topP传参:
15
+
16
+ ## 获取模型列表
17
+ ```
18
+ curl https:/http://127.0.0.1:7860/v1/models
19
+ ```
20
+ ## 聊天请求
21
+ ```
22
+ curl https://http://127.0.0.1:7860/v1/chat/completions \
23
+ -H "Content-Type: application/json" \
24
+ -H "Authorization: Bearer YOUR_API_KEY" \
25
+ -d '{
26
+ "model": "claude-3-5-sonnet-20241022",
27
+ "messages": [
28
+ {
29
+ "role": "user",
30
+ "content": "Hello, can you help me?"
31
+ }
32
+ ],
33
+ "temperature": 0.7,
34
+ "topP": 1
35
+ }'
36
+ ```
37
+ ## 抱脸部署
38
+ 下载文件,创建新的docker抱脸项目,然后上传文件,等待运行即可
39
+
40
+ ## 本地docker部署
41
+ 下载文件,然后创建镜像。
42
+
43
+ ```
44
+ docker build -t youname/partyrock2api .
45
+ ```
46
+ docker运行
47
+ ```
48
+ docker run -it -d --name partyrock2api \
49
+ --network=my_custom_network \
50
+ -p 7860:7860 \
51
+ -e API_KEY=your_api_key \
52
+ -e RedisUrl=your_RedisUrl \
53
+ -e RedisToken=your_RedisUrl \
54
+ -e AUTH_TOKENS_0_REFRESH_URL=your_referer \
55
+ -e AUTH_TOKENS_0_ANTI_CSRF_TOKEN=your_partyrock_anti-csrftoken-a2z\
56
+ -e AUTH_TOKENS_0_COOKIE=your_ partyrockCookie \
57
+ -e PORT=7860 \
58
+ youname/partyrock2api:latest
59
+ ```
60
+ ## 端口
61
+ - 默认端口:7860
62
+
63
+ ## 主要变量参数获取方式
64
+ 1、打开登录这个网站[partyrock](https://partyrock.aws/),然后创建一个聊天app.
65
+ ![image, 75%](https://github.com/user-attachments/assets/6df5667e-9726-4e83-a333-e4bd06e7f0f2)
66
+
67
+ 2、先打开f12,进入network界面,然后进行对话,完整复制下面的信息,分别为anti-csrftoken-a2z,Referer, Cookie的值,最好对话两次再获取cookie的值,有可能第一次没有验证用的waf cookie,导致后面报错400。
68
+ ![image, 75%](https://github.com/user-attachments/assets/b6af3cd8-5cea-4488-b804-ae07525c8a0e)
69
+
70
+ ![image, 75%](https://github.com/user-attachments/assets/73323b2d-000d-42de-973b-b8ed0eb7cef5)
71
+
72
+ 3、redis保护需要的token获取方式
73
+ 注册账号后创建数据库选择免费计划,然后在这里获取url和认证密钥填入环境变量。
74
+ ![image, 75%](https://github.com/user-attachments/assets/1c8afafa-ea18-43d0-92ba-0d5b4723e744)
75
+
76
+ 4、抱脸ip可能被封,可能需要反代,才能正常使用
77
+ 创建deno账号创建项目,复制如下代码,然后获取url
78
+ ```
79
+ import { serve } from "https://deno.land/[email protected]/http/server.ts";
80
+
81
+ const PROXY_DOMAIN = "https://partyrock.aws/stream/getCompletion";
82
+ const PORT = 8080;
83
+
84
+ async function handler(req: Request): Promise<Response> {
85
+ try {
86
+ const url = new URL(req.url);
87
+ const targetUrl = `${PROXY_DOMAIN}${url.pathname}${url.search}`;
88
+
89
+ const proxyResponse = await fetch(targetUrl, {
90
+ headers: req.headers,
91
+ method: req.method,
92
+ body: req.body
93
+ });
94
+
95
+ // 返回代理响应,保留状态码和响应头
96
+ return new Response(proxyResponse.body, {
97
+ status: proxyResponse.status,
98
+ headers: proxyResponse.headers
99
+ });
100
+ } catch (error) {
101
+ console.error("代理请求失败:", error);
102
+ return new Response("代理服务器错误", { status: 500 });
103
+ }
104
+ }
105
+ serve(handler, { port: PORT });
106
+ ```
107
+ ![image, 75%](https://github.com/user-attachments/assets/61f9d02d-90b4-4276-8d9b-cfbc932a4387)
108
+
109
+ ![image, 75%](https://github.com/user-attachments/assets/c3aef6cd-2582-4077-ad2b-067d8e7756ca)
110
+
111
+ ## 声明
112
+ 请勿用于商业用途。