-
Notifications
You must be signed in to change notification settings - Fork 13
/
types.go
77 lines (67 loc) · 2.06 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* @Author: Vincent Yang
* @Date: 2024-04-16 22:58:27
* @LastEditors: Vincent Yang
* @LastEditTime: 2024-04-19 19:42:31
* @FilePath: /cohere2openai/types.go
* @Telegram: https://t.me/missuo
* @GitHub: https://github.com/missuo
*
* Copyright © 2024 by Vincent, All Rights Reserved.
*/
package main
type OpenAIRequest struct {
Model string `json:"model"`
Messages []struct {
Role string `json:"role"`
Content string `json:"content"`
} `json:"messages"`
Stream bool `json:"stream"`
MaxTokens int64 `json:"max_tokens"`
}
type CohereRequest struct {
Model string `json:"model"`
ChatHistory []ChatMessage `json:"chat_history"`
Message string `json:"message"`
Stream bool `json:"stream"`
MaxTokens int64 `json:"max_tokens"`
}
type ChatMessage struct {
Role string `json:"role"`
Message string `json:"message"`
}
type CohereResponse struct {
IsFinished bool `json:"is_finished"`
EventType string `json:"event_type"`
Text string `json:"text,omitempty"`
FinishReason string `json:"finish_reason,omitempty"`
}
type OpenAIResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []OpenAIChoice `json:"choices"`
}
type OpenAIChoice struct {
Index int `json:"index"`
Delta OpenAIDelta `json:"delta"`
Logprobs interface{} `json:"logprobs"`
FinishReason *string `json:"finish_reason"`
}
type OpenAINonStreamResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []OpenAINonStreamChoice `json:"choices"`
}
type OpenAINonStreamChoice struct {
Index int `json:"index"`
Message OpenAIDelta `json:"message"`
FinishReason *string `json:"finish_reason"`
}
type OpenAIDelta struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
}