Spaces:
Sleeping
Sleeping
sanbo
commited on
Commit
·
3101f66
1
Parent(s):
6390a71
update sth. at 2024-12-18 21:12:21
Browse files
README.md
CHANGED
@@ -1,60 +1,51 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 🦀
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
6 |
sdk: docker
|
7 |
pinned: true
|
8 |
app_port: 7860
|
9 |
-
short_description:
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
|
14 |
# 请求
|
15 |
|
16 |
-
*
|
17 |
|
18 |
``` bash
|
19 |
-
curl https
|
20 |
```
|
21 |
|
22 |
-
*
|
23 |
-
|
24 |
``` bash
|
25 |
-
curl --location --request POST 'https
|
26 |
--header 'Content-Type: application/json' \
|
27 |
--data-raw '{
|
28 |
"model": "gpt-4o-mini",
|
29 |
"messages": [
|
30 |
{
|
31 |
"role": "user",
|
32 |
-
"content": "
|
33 |
}
|
34 |
],
|
35 |
"stream": true
|
36 |
}'
|
37 |
|
38 |
|
39 |
-
|
40 |
-
curl --location --request POST 'http://0.0.0.0:7860/completions' \
|
41 |
--header 'Content-Type: application/json' \
|
42 |
--data-raw '{
|
43 |
"model": "gpt-4o-mini",
|
44 |
"messages": [
|
45 |
{
|
46 |
"role": "user",
|
47 |
-
"content": "
|
48 |
}
|
49 |
],
|
50 |
"stream": true
|
51 |
}'
|
52 |
|
53 |
-
```
|
54 |
-
|
55 |
-
# support models
|
56 |
-
|
57 |
-
- claude-3-haiku
|
58 |
-
- llama-3.1-70b
|
59 |
-
- mixtral-8x7b
|
60 |
-
- gpt-4o-mini
|
|
|
1 |
---
|
2 |
+
title: ddchat
|
3 |
emoji: 🦀
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
6 |
sdk: docker
|
7 |
pinned: true
|
8 |
app_port: 7860
|
9 |
+
short_description: ddchat
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
|
14 |
# 请求
|
15 |
|
16 |
+
* 获取模式
|
17 |
|
18 |
``` bash
|
19 |
+
curl https://sanbo1200-ddghat.hf.space/models
|
20 |
```
|
21 |
|
22 |
+
* 发起对话请求
|
|
|
23 |
``` bash
|
24 |
+
curl --location --request POST 'https://sanbo1200-ddghat.hf.space/completions' \
|
25 |
--header 'Content-Type: application/json' \
|
26 |
--data-raw '{
|
27 |
"model": "gpt-4o-mini",
|
28 |
"messages": [
|
29 |
{
|
30 |
"role": "user",
|
31 |
+
"content": "你是什么模型?你的知识库截止到什么时间?"
|
32 |
}
|
33 |
],
|
34 |
"stream": true
|
35 |
}'
|
36 |
|
37 |
|
38 |
+
curl --location --request POST 'http://0.0.0.0:8760/completions' \
|
|
|
39 |
--header 'Content-Type: application/json' \
|
40 |
--data-raw '{
|
41 |
"model": "gpt-4o-mini",
|
42 |
"messages": [
|
43 |
{
|
44 |
"role": "user",
|
45 |
+
"content": "你是什么模型?你的知识库截止到什么时间?"
|
46 |
}
|
47 |
],
|
48 |
"stream": true
|
49 |
}'
|
50 |
|
51 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.go
CHANGED
@@ -337,6 +337,43 @@ func handleCompletion(c *gin.Context) {
|
|
337 |
}
|
338 |
}
|
339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
func requestToken() (string, error) {
|
341 |
url := "https://duckduckgo.com/duckchat/v1/status"
|
342 |
client := &http.Client{
|
|
|
337 |
}
|
338 |
}
|
339 |
|
340 |
+
//func requestToken() (string, error) {
|
341 |
+
// req, err := http.NewRequest("GET", "https://duckduckgo.com/duckchat/v1/status", nil)
|
342 |
+
// if err != nil {
|
343 |
+
// return "", fmt.Errorf("创建请求失败: %v", err)
|
344 |
+
// }
|
345 |
+
// for k, v := range config.FakeHeaders {
|
346 |
+
// req.Header.Set(k, v)
|
347 |
+
// }
|
348 |
+
// req.Header.Set("x-vqd-accept", "1")
|
349 |
+
//
|
350 |
+
// client := &http.Client{
|
351 |
+
// Timeout: 10 * time.Second,
|
352 |
+
// }
|
353 |
+
//
|
354 |
+
// log.Println("发送 token 请求")
|
355 |
+
// resp, err := client.Do(req)
|
356 |
+
// if err != nil {
|
357 |
+
// return "", fmt.Errorf("请求失败: %v", err)
|
358 |
+
// }
|
359 |
+
// defer resp.Body.Close()
|
360 |
+
//
|
361 |
+
// if resp.StatusCode != http.StatusOK {
|
362 |
+
// bodyBytes, _ := io.ReadAll(resp.Body)
|
363 |
+
// bodyString := string(bodyBytes)
|
364 |
+
// log.Printf("requestToken: 非200响应: %d, 内容: %s\n", resp.StatusCode, bodyString)
|
365 |
+
// return "", fmt.Errorf("非200响应: %d, 内容: %s", resp.StatusCode, bodyString)
|
366 |
+
// }
|
367 |
+
//
|
368 |
+
// token := resp.Header.Get("x-vqd-4")
|
369 |
+
// if token == "" {
|
370 |
+
// return "", errors.New("响应中未包含x-vqd-4头")
|
371 |
+
// }
|
372 |
+
//
|
373 |
+
// // log.Printf("获取到的 token: %s\n", token)
|
374 |
+
// return token, nil
|
375 |
+
//}
|
376 |
+
|
377 |
func requestToken() (string, error) {
|
378 |
url := "https://duckduckgo.com/duckchat/v1/status"
|
379 |
client := &http.Client{
|