usage_detail.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/dialect/entsql"
  5. "entgo.io/ent/schema"
  6. "entgo.io/ent/schema/field"
  7. "entgo.io/ent/schema/index"
  8. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  9. )
  10. type UsageDetail struct {
  11. ent.Schema
  12. }
  13. func (UsageDetail) Fields() []ent.Field {
  14. return []ent.Field{
  15. field.Int("type").Optional().Default(1).
  16. Annotations(entsql.WithComments(true)).
  17. Comment("1 微信 2 名片"),
  18. field.String("bot_id").Default("").
  19. Annotations(entsql.WithComments(true)).
  20. Comment("微信或名片id"),
  21. field.String("receiver_id").Default("").
  22. Annotations(entsql.WithComments(true)).
  23. Comment("微信id或open_id"),
  24. field.Int("app").Optional().Default(1).
  25. Annotations(entsql.WithComments(true)).
  26. Comment("1 cow-basic 2 cow-agent 3 cow-sop 4 mp-card 5 mp-employee"),
  27. field.Uint64("session_id").Optional().Default(1).
  28. Comment("名片会话id").
  29. Annotations(entsql.WithComments(true)),
  30. field.String("request").Default("").
  31. Annotations(entsql.WithComments(true)).
  32. Comment("请求内容"),
  33. field.String("response").Default("").
  34. Annotations(entsql.WithComments(true)).
  35. Comment("响应内容"),
  36. field.Uint64("total_tokens").Optional().Default(0).
  37. Annotations(entsql.WithComments(true)).
  38. Comment("使用token总数"),
  39. field.Uint64("prompt_tokens").Optional().Default(0).
  40. Annotations(entsql.WithComments(true)).
  41. Comment("请求token数"),
  42. field.Uint64("completion_tokens").Optional().Default(0).
  43. Annotations(entsql.WithComments(true)).
  44. Comment("响应token数"),
  45. field.Uint64("organization_id").Optional().Default(1).
  46. Comment("机构 ID").
  47. Annotations(entsql.WithComments(true)),
  48. }
  49. }
  50. func (UsageDetail) Mixin() []ent.Mixin {
  51. return []ent.Mixin{
  52. mixins.IDMixin{},
  53. mixins.StatusMixin{},
  54. }
  55. }
  56. func (UsageDetail) Indexes() []ent.Index {
  57. return []ent.Index{
  58. index.Fields("bot_id"),
  59. index.Fields("organization_id"),
  60. }
  61. }
  62. func (UsageDetail) Edges() []ent.Edge { return []ent.Edge{} }
  63. func (UsageDetail) Annotations() []schema.Annotation {
  64. return []schema.Annotation{
  65. entsql.WithComments(true),
  66. entsql.Annotation{Table: "usage_detail"},
  67. }
  68. }