ollama_registry.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package llm
  2. import (
  3. "yunion.io/x/jsonutils"
  4. )
  5. type SOllamaTag struct {
  6. Name string `json:"name" yaml:"name"`
  7. ModelSize string `json:"model_size" yaml:"model_size"`
  8. ContextLength string `json:"context_length" yaml:"context_length"`
  9. Capabilities []string `json:"capabilities" yaml:"capabilities"`
  10. IsLatest bool `json:"is_latest,omitempty" yaml:"is_latest,omitempty"`
  11. }
  12. func (t SOllamaTag) Latest() SOllamaTag {
  13. t.IsLatest = true
  14. return t
  15. }
  16. type SOllamaModel struct {
  17. Name string `json:"name" yaml:"name"`
  18. Description string `json:"description" yaml:"description"`
  19. Tags []SOllamaTag `json:"tags" yaml:"tags"`
  20. }
  21. // SOllamaRegistry 顶层结构,用于生成
  22. // ollama:
  23. // - name: xxx
  24. // ...
  25. type SOllamaRegistry struct {
  26. Ollama []SOllamaModel `json:"ollama" yaml:"ollama"`
  27. }
  28. func NewOllamaTag(name, size, contextLen string, caps []string) SOllamaTag {
  29. return SOllamaTag{
  30. Name: name,
  31. ModelSize: size,
  32. ContextLength: contextLen,
  33. Capabilities: caps,
  34. }
  35. }
  36. func NewOllamaModel(name, desc string, tags ...SOllamaTag) SOllamaModel {
  37. return SOllamaModel{
  38. Name: name,
  39. Description: desc,
  40. Tags: tags,
  41. }
  42. }
  43. func NewOllamaRegistry(models ...SOllamaModel) SOllamaRegistry {
  44. return SOllamaRegistry{
  45. Ollama: models,
  46. }
  47. }
  48. var (
  49. CapText = []string{"Text"}
  50. CapVision = []string{"Text", "Image"}
  51. )
  52. var OllamaRegistry = NewOllamaRegistry(
  53. NewOllamaModel(
  54. "qwen3-vl",
  55. "Qwen3-vl is the most powerful vision-language model in the Qwen model family to date.",
  56. NewOllamaTag("2b", "1.9GB", "256K", CapVision),
  57. NewOllamaTag("4b", "3.3GB", "256K", CapVision),
  58. NewOllamaTag("8b", "6.1GB", "256K", CapVision).Latest(),
  59. NewOllamaTag("30b", "20GB", "256K", CapVision),
  60. NewOllamaTag("32b", "21GB", "256K", CapVision),
  61. ),
  62. NewOllamaModel(
  63. "qwen3",
  64. "Qwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models.",
  65. NewOllamaTag("0.6b", "523MB", "40K", CapText),
  66. NewOllamaTag("1.7b", "1.4GB", "40K", CapText),
  67. NewOllamaTag("4b", "2.5GB", "256K", CapText),
  68. NewOllamaTag("8b", "5.2GB", "40K", CapText).Latest(),
  69. NewOllamaTag("14b", "9.3GB", "40K", CapText),
  70. NewOllamaTag("30b", "19GB", "256K", CapText),
  71. NewOllamaTag("32b", "20GB", "40K", CapText),
  72. ),
  73. NewOllamaModel(
  74. "qwen2.5-coder",
  75. "The latest series of Code-Specific Qwen models, with significant improvements in code generation, code reasoning, and code fixing.",
  76. NewOllamaTag("latest", "4.7GB", "32K", CapText),
  77. NewOllamaTag("0.5b", "398MB", "32K", CapText),
  78. NewOllamaTag("1.5b", "986MB", "32K", CapText),
  79. NewOllamaTag("3b", "1.9GB", "32K", CapText),
  80. NewOllamaTag("7b", "4.7GB", "32K", CapText).Latest(),
  81. NewOllamaTag("14b", "9.0GB", "32K", CapText),
  82. NewOllamaTag("32b", "20GB", "32K", CapText),
  83. ),
  84. )
  85. var OLLAMA_REGISTRY_YAML = jsonutils.Marshal(OllamaRegistry).YAMLString()