Skip to content

Commit 15c4919

Browse files
authored
feat(groq): update codebase to support new AI models (#155)
- Update model references from `LLaMA2-70b-chat`, `Mixtral-8x7b-Instruct-v0.1`, and `Gemma-7b-it` to `llama3-8b-8192`, `llama3-70b-8192`, `mixtral-8x7b-32768`, and `gemma-7b-it` in README.md - Replace old model constants with new ones in `groq/model.go` - Remove deprecated `GetModel` function from `groq/model.go` - Update model validation cases to use new model constants in `groq/model.go` - Update model mappings in `openai/openai.go` to reflect new model constants - Adjust completion function in `openai/openai.go` to use new model strings - Add new models to the allowed function call list in `openai/openai.go` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent e6a5a52 commit 15c4919

File tree

3 files changed

+51
-61
lines changed

3 files changed

+51
-61
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ Please get the `API key` from Groq API Service, please vist [here][31]. Update t
123123
codegpt config set openai.provider openai
124124
codegpt config set openai.base_url https://api.groq.com/openai/v1
125125
codegpt config set openai.api_key gsk_xxxxxxxxxxxxxx
126-
codegpt config set openai.model LLaMA2-70b-chat
126+
codegpt config set openai.model llama3-8b-8192
127127
```
128128

129129
Support the [following models][32]:
130130

131-
1. LLaMA2-70b-chat (Meta) **recommended**
132-
2. Mixtral-8x7b-Instruct-v0.1 (Mistral)
133-
3. Gemma-7b-it (Google)
131+
1. `llama3-8b-8192` (Meta) **recommended**
132+
2. `llama3-70b-8192` (Meta)
133+
3. `mixtral-8x7b-32768` (Mistral)
134+
4. `gemma-7b-it` (Google)
134135

135136
[30]: https://groq.com/
136137
[31]: https://console.groq.com/keys

groq/model.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,21 @@ package groq
33
type Model string
44

55
const (
6-
LLaMA270bChat Model = "LLaMA2-70b-chat"
7-
Mixtral8x7bInstructV01 Model = "Mixtral-8x7b-Instruct-v0.1"
8-
Gemma7bIt Model = "Gemma-7b-it"
6+
LLaMA38b Model = "llama3-8b-8192" //
7+
LLaMA370b Model = "llama3-70b-8192"
8+
Mixtral8x7b Model = "mixtral-8x7b-32768"
9+
Gemma7b Model = "gemma-7b-it"
910
)
1011

1112
func (m Model) String() string {
1213
return string(m)
1314
}
1415

15-
func (m Model) GetModel() string {
16-
return GetModel(m)
17-
}
18-
1916
func (m Model) IsVaild() bool {
2017
switch m {
21-
case LLaMA270bChat, Mixtral8x7bInstructV01, Gemma7bIt:
18+
case LLaMA38b, LLaMA370b, Mixtral8x7b, Gemma7b:
2219
return true
2320
default:
2421
return false
2522
}
2623
}
27-
28-
var model = map[Model]string{
29-
LLaMA270bChat: "llama2-70b-4096",
30-
Mixtral8x7bInstructV01: "mixtral-8x7b-32768",
31-
Gemma7bIt: "gemma-7b-it",
32-
}
33-
34-
// GetModel returns the model name.
35-
func GetModel(modelName Model) string {
36-
if _, ok := model[modelName]; !ok {
37-
return model[LLaMA270bChat]
38-
}
39-
return model[modelName]
40-
}

openai/openai.go

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,38 @@ var DefaultModel = openai.GPT3Dot5Turbo
1818

1919
// modelMaps maps model names to their corresponding model ID strings.
2020
var modelMaps = map[string]string{
21-
"gpt-4-32k-0613": openai.GPT432K0613,
22-
"gpt-4-32k-0314": openai.GPT432K0314,
23-
"gpt-4-32k": openai.GPT432K,
24-
"gpt-4-0613": openai.GPT40613,
25-
"gpt-4-0314": openai.GPT40314,
26-
"gpt-4-turbo": openai.GPT4Turbo,
27-
"gpt-4-turbo-2024-04-09": openai.GPT4Turbo20240409,
28-
"gpt-4-0125-preview": openai.GPT4Turbo0125,
29-
"gpt-4-1106-preview": openai.GPT4Turbo1106,
30-
"gpt-4-turbo-preview": openai.GPT4TurboPreview,
31-
"gpt-4-vision-preview": openai.GPT4VisionPreview,
32-
"gpt-4": openai.GPT4,
33-
"gpt-3.5-turbo-0125": openai.GPT3Dot5Turbo0125,
34-
"gpt-3.5-turbo-1106": openai.GPT3Dot5Turbo1106,
35-
"gpt-3.5-turbo-0613": openai.GPT3Dot5Turbo0613,
36-
"gpt-3.5-turbo-0301": openai.GPT3Dot5Turbo0301,
37-
"gpt-3.5-turbo-16k": openai.GPT3Dot5Turbo16K,
38-
"gpt-3.5-turbo-16k-0613": openai.GPT3Dot5Turbo16K0613,
39-
"gpt-3.5-turbo": openai.GPT3Dot5Turbo,
40-
"gpt-3.5-turbo-instruct": openai.GPT3Dot5TurboInstruct,
41-
"davinci": openai.GPT3Davinci,
42-
"davinci-002": openai.GPT3Davinci002,
43-
"curie": openai.GPT3Curie,
44-
"curie-002": openai.GPT3Curie002,
45-
"ada": openai.GPT3Ada,
46-
"ada-002": openai.GPT3Ada002,
47-
"babbage": openai.GPT3Babbage,
48-
"babbage-002": openai.GPT3Babbage002,
49-
groq.LLaMA270bChat.String(): groq.LLaMA270bChat.GetModel(),
50-
groq.Mixtral8x7bInstructV01.String(): groq.Mixtral8x7bInstructV01.GetModel(),
51-
groq.Gemma7bIt.String(): groq.Gemma7bIt.GetModel(),
21+
"gpt-4-32k-0613": openai.GPT432K0613,
22+
"gpt-4-32k-0314": openai.GPT432K0314,
23+
"gpt-4-32k": openai.GPT432K,
24+
"gpt-4-0613": openai.GPT40613,
25+
"gpt-4-0314": openai.GPT40314,
26+
"gpt-4-turbo": openai.GPT4Turbo,
27+
"gpt-4-turbo-2024-04-09": openai.GPT4Turbo20240409,
28+
"gpt-4-0125-preview": openai.GPT4Turbo0125,
29+
"gpt-4-1106-preview": openai.GPT4Turbo1106,
30+
"gpt-4-turbo-preview": openai.GPT4TurboPreview,
31+
"gpt-4-vision-preview": openai.GPT4VisionPreview,
32+
"gpt-4": openai.GPT4,
33+
"gpt-3.5-turbo-0125": openai.GPT3Dot5Turbo0125,
34+
"gpt-3.5-turbo-1106": openai.GPT3Dot5Turbo1106,
35+
"gpt-3.5-turbo-0613": openai.GPT3Dot5Turbo0613,
36+
"gpt-3.5-turbo-0301": openai.GPT3Dot5Turbo0301,
37+
"gpt-3.5-turbo-16k": openai.GPT3Dot5Turbo16K,
38+
"gpt-3.5-turbo-16k-0613": openai.GPT3Dot5Turbo16K0613,
39+
"gpt-3.5-turbo": openai.GPT3Dot5Turbo,
40+
"gpt-3.5-turbo-instruct": openai.GPT3Dot5TurboInstruct,
41+
"davinci": openai.GPT3Davinci,
42+
"davinci-002": openai.GPT3Davinci002,
43+
"curie": openai.GPT3Curie,
44+
"curie-002": openai.GPT3Curie002,
45+
"ada": openai.GPT3Ada,
46+
"ada-002": openai.GPT3Ada002,
47+
"babbage": openai.GPT3Babbage,
48+
"babbage-002": openai.GPT3Babbage002,
49+
groq.LLaMA38b.String(): groq.LLaMA38b.String(),
50+
groq.LLaMA370b.String(): groq.LLaMA370b.String(),
51+
groq.Mixtral8x7b.String(): groq.Mixtral8x7b.String(),
52+
groq.Gemma7b.String(): groq.Gemma7b.String(),
5253
}
5354

5455
// GetModel returns the model ID corresponding to the given model name.
@@ -194,9 +195,10 @@ func (c *Client) Completion(
194195
openai.GPT4VisionPreview,
195196
openai.GPT4Turbo,
196197
openai.GPT4Turbo20240409,
197-
groq.LLaMA270bChat.GetModel(),
198-
groq.Mixtral8x7bInstructV01.GetModel(),
199-
groq.Gemma7bIt.GetModel():
198+
groq.LLaMA38b.String(),
199+
groq.LLaMA370b.String(),
200+
groq.Mixtral8x7b.String(),
201+
groq.Gemma7b.String():
200202
r, err := c.CreateChatCompletion(ctx, content)
201203
if err != nil {
202204
return nil, err
@@ -323,7 +325,11 @@ func (c *Client) allowFuncCall(cfg *config) bool {
323325
openai.GPT3Dot5Turbo,
324326
openai.GPT3Dot5Turbo0125,
325327
openai.GPT3Dot5Turbo0613,
326-
openai.GPT3Dot5Turbo1106:
328+
openai.GPT3Dot5Turbo1106,
329+
groq.LLaMA38b.String(),
330+
groq.LLaMA370b.String(),
331+
groq.Mixtral8x7b.String(),
332+
groq.Gemma7b.String():
327333
return true
328334
default:
329335
return false

0 commit comments

Comments
 (0)